My database has a number of modules that import data from multiple Excel tables which I receive from multiple people. After using "DoCmd.TransferSpreadsheet" to load the data into the first 33 fields of a staging table (tbl_current_import), I update the 34th field with a value representing the company department of the person submitting the Excel sheet. I then execute a number of other queries to move the information from the staging table to the other db tables as needed. I have 56 modules each with the following code:
' Import the current template into the "tbl_current_import" table.
DoCmd.TransferSpreadsheet acImport, 8, "tbl_current_import", "\\myserver\myfolder\DeptName Budget Final.xls", False, "Budget Summary!a7:ag5007"
' Insert the Division_ID into position F34 of each record the "tbl_current_import" table.
DoCmd.RunSQL "UPDATE tbl_current_import SET tbl_current_import.F34 = ""13"" WHERE (((tbl_current_import.F1) Is Not Null)); ", -1
The only difference between the modules is the name of the Excel file and the value that gets plugged into field "F34".
I would like to replace the sql statement above with this querydef (qry_update_tbl_current_import):
UPDATE tbl_current_import SET tbl_current_import.F34 = [divID_Parameter]
WHERE (((tbl_current_import.F1) Is Not Null));
And, I would like to pass the querydef the parameter value for [divID_Parameter] from the module:
IE: 1. Open query "qry_update_tbl_current_import"
2. Set [divID_Parameter] = "13"
3. Execute & Close the query.
I am a total novice with vba and I need help with the syntax to do this.
Thanks in advance for your help!
' Import the current template into the "tbl_current_import" table.
DoCmd.TransferSpreadsheet acImport, 8, "tbl_current_import", "\\myserver\myfolder\DeptName Budget Final.xls", False, "Budget Summary!a7:ag5007"
' Insert the Division_ID into position F34 of each record the "tbl_current_import" table.
DoCmd.RunSQL "UPDATE tbl_current_import SET tbl_current_import.F34 = ""13"" WHERE (((tbl_current_import.F1) Is Not Null)); ", -1
The only difference between the modules is the name of the Excel file and the value that gets plugged into field "F34".
I would like to replace the sql statement above with this querydef (qry_update_tbl_current_import):
UPDATE tbl_current_import SET tbl_current_import.F34 = [divID_Parameter]
WHERE (((tbl_current_import.F1) Is Not Null));
And, I would like to pass the querydef the parameter value for [divID_Parameter] from the module:
IE: 1. Open query "qry_update_tbl_current_import"
2. Set [divID_Parameter] = "13"
3. Execute & Close the query.
I am a total novice with vba and I need help with the syntax to do this.
Thanks in advance for your help!