Please help, I have wondered this forum and the internet for help with no success. I have a button on a access database form that runs a query and exports the data to an excel sheet that remains open. I am ok with this. What I would like to do now is format the sheet and then save it as a file name that is the same as the query name but adding the date at the end. Here is what I have so far:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
stDocName = "Qry_SentForProcessing"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.RunSavedImportExport "Export-Qry_SentForProcessing"
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
I just want to add the code to this button. Or do I need to write a function as a module, then call the function after the export is run. Any assistance is greatly appreciated.
Thanks
David V
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
stDocName = "Qry_SentForProcessing"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.RunSavedImportExport "Export-Qry_SentForProcessing"
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
I just want to add the code to this button. Or do I need to write a function as a module, then call the function after the export is run. Any assistance is greatly appreciated.
Thanks
David V