troubleshooting Question

DoCmd.SendObject acSendQuery command problems

Avatar of ckangas7
ckangas7 asked on
Microsoft AccessVB Script
5 Comments1 Solution1650 ViewsLast Modified:
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, _
    "", "", , _
    "Store Reports", "Here are your reports.", True
End Sub

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros