MS Access Open Query Results in Excel Spreadsheet

Hello,

I have a command button on a MS Access form.  I want the click event to run an SQL query and show the results in an excel spreadsheet.  I want the user to have the option of saving the spreadsheet or just closing the spreadsheet out.  Is there a way to do this every method I've tried prompts you to save the spreadsheet first to a file location.  Example:

DoCmd.OutputTo objecttype:=acOutputQuery, objectname:="Parent and Child Benefit Rules", outputformat:=acFormatXLS

Thanks
Paul SchulerSystems Production Support AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeCommented:
Have you tried the transfer spreadsheet method?  I cannot remember whether that meets your needs or not.

You could us automation to open Excel, create a new workbook, and the use the Range.CopyFromRecordset method to do this.

Takes quite a bit more code, but can be done in under 20 lines of code.

I'm currently sitting in a waiting room, and don't have access to Access, but searching here in EE on the term CopyFromRecordset returned this recent post with code.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PatHartmanCommented:
The built in methods always save the spreadsheet.  You will have to use OLE automation to do what you are requesting.  In VBA, you would open Excel and then transfer the data to it, and finally make Excel visible.  The user is then in Excel and he can save or not when he exits.
0
MacroShadowCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Dale Fye (https:#a42432816)
-- PatHartman (https:#a42432818)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

MacroShadow
Experts-Exchange Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.