This is a follow on question to a prior thread where I posed the question regarding how to create a new record in a table that I use for capturing control information about date ranges of info being imported to another table.
Here is link to prior question for reference
Prior Question Link
I am importing a date range of GL Transactions at various times (usually once per month). I wanted a control table to maintain the range of dates of what was being imported as well as the date that the import happened.
THIS QUESTION deals with when I import the thousands of records of GL Transactions how can I capture the ID# of that Control record I just created and pass it back to all of the records being imported and added as a field to each of the records being imported at that time.
Below is my Event Procedure on On Click where it executes a "SavedImport" to get all of the transactions from the Excel sheet and Imports those transactions into the table named "QB GL Transactions". The table that has the newly created control ID is "Data Import Control".
Private Sub cmdImportGLTransactions_Click()
On Error GoTo cmdCloseImport_Click_Err
CurrentDb.Execute "INSERT INTO [Data Import Control]([BeginningTransactDate],[EndingTransactDate], [EarliestInputDate],[LatestInputDate]) SELECT [Beginning Transact Date], [Ending Transact Date], [Earliest Input Date], [Latest Input Date] FROM [GL Transaction Import Date Ranges]"
MsgBox "Your data has been Imported from Excel", vbOKOnly, "Excel Data Imported"