I am importing multiple logs to the DB and process them monthly. My requirement is to skip the log files which are already imported once. I am using a 'For' loop for importing the selected files. If anyone came across these kind of requirements in the MS access vba, please help.
I am using 'Go To' as work around but doesn't feel like a professional approach.
Dim txtImportFileName, txtImportedTbleName, txtImportRange, txtImportedLogTbleName, txtSelectedFiles() As String
Dim intNumOfFiles, intX, intNumOfRecords As Integer
intNumOfFiles = mFilePicker("Please select the Log files", "c:\temp\", "Excel files", "*.xlsx", txtSelectedFiles)
txtImportedTbleName = "tmp_Log"
txtImportedLogTbleName = "031_Log"
txtImportRange = ""
If Confirmation("Please confirm/ご確認ください", "Do you want to import " & intNumOfFiles & "Files?") Then
For intX = 1 To intNumOfFiles
txtImportFileName = txtSelectedFiles(intX)
txtSQLcmd = "SELECT [00_ImportedFiles].FileName FROM 00_ImportedFiles "
txtSQLcmd = txtSQLcmd & "WHERE ((([00_ImportedFiles].FileName) ALike '" & txtImportFileName & "'));"
intNumOfRecords = CountQueryRecords(txtSQLcmd) 'calling a function to count the number of records in the Imported File list table
If (intNumOfRecords > 0) Then
Debug.Print intNumOfRecords
GoTo Skip
End If
Call ImportFromExcel(txtImportFileName, txtImportedTbleName, txtImportRange)
'Call Delete_Tables(txtImportedLogTbleName)
txtSQLcmd = "SELECT F1, F2, F3, F4, F5, F6 INTO " & txtImportedLogTbleName & " "
txtSQLcmd = txtSQLcmd & "FROM " & txtImportedTbleName & " "
txtSQLcmd = txtSQLcmd & "WHERE (((F1)<>'日付') AND ((F2)<>''));"
Call ExecuteSQLcmd(txtSQLcmd)
Call Delete_Tables(txtImportedTbleName)
Skip:
Next intX
Could someone propose a better/formal way of doing this?