I have this code that loads data from Excel to my tables in Access. I have the last column as [Load_date] in all my tables, and in Design View of my tables I am using the function =Now()
for the Default Value.
My problem is each of my table has different time stamp differ by few seconds. How can I update my VBA Code to import data in all tables at the exact same time?
Sub ImportAllTables_New_Click()
Call LoadData("C:\Idea Attributes\tbl_IdeasITAssumptions.xlsm", "TempIdeasITAssumptions", "Qry_IdeasITAssumptions", "Qry_AppendIdeasITAssumptions")
Call LoadData("C:\Idea Attributes\tbl_IdeasDependencies.xlsm", "TempIdeasDependencies", "Qry_IdeasDependencies", "Qry_AppendIdeasDependencies")
Call LoadData("C:\Idea Attributes\tbl_IdeasImpactedPlan.xlsm", "TempIdeasImpactedPlan", "Qry_IdeasImpactedPlan", "Qry_AppendIdeasImpactedPlan")
Call LoadData("C:\Idea Attributes\tbl_IdeasImpactedSubsidiaries.xlsm", "TempIdeasImpactedSubsidiaries", "Qry_IdeasImpactedSubsidiaries", "Qry_AppendIdeasImpactedSubsidiaries")
Call LoadData("C:\Idea Attributes\tbl_IdeasLOB.xlsm", "TempIdeasLOB", "Qry_IdeasLOB", "Qry_AppendIdeasLOB")
Call LoadData("C:\Idea Attributes\tbl_IdeasPhaseGate.xlsm", "TempIdeasPhaseGate", "Qry_IdeasPhaseGate", "Qry_AppendIdeasPhaseGate")
Call LoadData("C:\Idea Attributes\tbl_IdeasDataExtractMain.xlsm", "TempIdeasDataExtractMain", "Qry_IdeasDataExtractMain", "Qry_AppendIdeasDataExtractMain")
End Sub
Sub LoadData(Filepath As String, TempTable As String, Qry_Ideas As Variant, Qry_Append As Variant)
If FileExist(Filepath) Then
DoCmd.TransferSpreadsheet acImport, , TempTable, Filepath, True
'The following will Check for new Load_Date , if it is not new you will get no new data msg. This function is currently not useful since we are using Now() function in our tables.
'But if in future we need to use it, delete now() in tables it self under Load_Date Default Value.
If IsNull(DLookup("(idea_code)", Qry_Ideas)) Then
MsgBox "No New Data to add"
Else
DoCmd.OpenQuery Qry_Append, acViewNormal
End If
Else
MsgBox "File not found. Please check the filename or File Location."
End If
'Use Sql Command to delete everything in Temp Table
Dim SQLDelete As String
SQLDelete = "Delete * from " & TempTable
DoCmd.RunSQL SQLDelete
End Sub