Use textbox value in Form to Change file location in saved import specs (MS Access)
Hi Guys & Gals,
I'm working on an Access project (MS access 2010) & I have an unbound form called "Import Into Account" that I have a file picker/browser to choose the file to import and I want to have VBA update the saved import spec to the file chosen in the file picker/browser on the form, then execute an update query and close the form. I think I have most of the moving pieces good to go, but I don't know how to the file location in the saved import specs to change. Here's the info:
Form Name: Import Into Account
File Path for import csv file: txtImportFileLocation (unbound text box on form)
"filter" for which saved import specs to use: cbImportAccount (unbound dropdown with a list of account names)
button to make it all go: btnImportAccountRunQuery
The saved import specs are named "Chase" and "GTK" & I want it to work like:
Private Sub btnImportAccountRunQuery_Click()If cbImportAccount = 2 Or cbImportAccount = 3 Then ImportSpecifications = "Chase" ImportFilelocation = txtImportFileLocation DoCmd.OpenQuery "Chase Import Query", acViewNormal, acEditDim UpdateImportedSQL As StringUpdateImportedSQL = "UPDATE [Chase Import] " & _ "SET Imported = TRUE; "DoCmd.RunSQL UpdateImportedSQLDoCmd.Close acForm, "Import Into Account"Else If If cbImportAccount = 12 Then ImportSpecifications = "GTK" ImportFilelocation = txtImportFileLocation DoCmd.OpenQuery "GTK Import Query", acViewNormal, acEditDim UpdateImportedSQL As StringUpdateImportedSQL = "UPDATE [GTK Import] " & _ "SET Imported = TRUE; "DoCmd.RunSQL UpdateImportedSQLDoCmd.Close acForm, "Import Into Account"End IfEnd Sub
worked perfectly, thank you for your help!