Access VB to caputure a Control Table record ID and pass it back to use as a field in records being imported to another table

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
    DoCmd.RunSavedImportExport "Import-QBGLTransactions"
    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"
    Exit Sub

    MsgBox "Error$"
    Exit Sub
End Sub

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There isn't any way you can get inside an Import to add extra data or fields.
You would have to complete your import of transactions and then run an update query to apply the controlId to the imported records  as below.

Assuming your ControlID is an autonumber or other sequential number, you can get it from the import control table using a DMAX() function.

dim strsql as string
Dim MaxID as long
MaxiD= dmax("[ControlIDFieldname]", "[Data Import Control]")
strsql = "Update [QB GL Transactions] set [controlidfieldname] = " maxid & " where [Controlidfieldname] is null"
currentdb.execute strsql, dbfailonerror

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wlwebbAuthor Commented:
Just got back into town.  I will attempt this tomorrow.  Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.