Have the below sub assigned to a button on a form in Access. It runs but am having some issues with it.
1. Is there any way that I can pass parameters with this command to the query? I want the parameters to be passed automatically without the user having to type them in.
2. For some reason after running this my store_report query is erased. The query still shows as an object, but if you open it the sql contents are all gone, thus the query will not run. I've noticed that this sometimes happens if I right click on the query and do an export to an excel file. After doing the export the sql contents of the query dissappear. Any way to prevent that?
3. Can I specify an excel template file to send the data to and specify what cells to begin inserting data to?
Sorry for so many questions. Am assigning max points. I think I am probably going to need different code to do all this, but I have no idea what I need.
Private Sub Email_Click()
DoCmd.SendObject acSendQuery, "store_report", acFormatXLS, _
"firstname.lastname@example.org", "email@example.com", , _
"Store Reports", "Here are your reports.", True