Hi
I am using a vba code to import excel file to ms access. As per the requirement i need to generate a log file for the successful/failure of the import. I am not sure how to do this any help will be appreciated.
I am doing the following steps.
below is my code:
Option Compare Database
Private Sub Form_Current()
Dim Filepath As String
Filepath = "C:\Users\Subhasmita\Desktop\Work\Project\ACH Reject Data.xlsx"
If FileExist(Filepath) Then
DoCmd.TransferSpreadsheet acImport, , "TempFromExcel", Filepath, True
If IsNull(DLookup("[Z_UPDT]", "NewData")) Then
MsgBox "No new data to add"
Else
MsgBox User & " file " & strFileName & "is (re-)created"
DoCmd.OpenQuery "qryAppend", acViewNormal
DoCmd.SetWarnings off
End If
Else
MsgBox "File Not Found.Check File name or location."
End If
Dim SQLDelete As String
SQLDelete = "Delete * From TempFromExcel"
DoCmd.RunSQL SQLDelete
DoCmd.SetWarnings off
End Sub
Function FileExist(sTestFile As String) As Boolean
Dim lSize As Long
On Error Resume Next
'Present lenght to -1 because file length can be zero
lSize = -1
'Get the length of the file
lSize = FileLen(sTestFile)
If lSize > -1 Then
FileExist = True
Else
End If
End Function