I have a database that currently when you click the button on the form, it opens the report "rpt_Test".
I have to then manually view it with excel and save it.
I'm looking for a code that will do the following:
1) Click the button on form = msgbox ("View report or export?") vbyesno
2) Yes = View report
2a) No = Export into S:\Testing\TestReport.xls
2b) msgbox ("Successfully exported!")
3) exit report view and just show form
I tried looking through the macro commands and couldn't find anything, so i'm ok using VBA instead
Thanks for all the help!
Last edited by adgjqetuo; 11-20-2009 at 08:49 AM.
Hi,
Is "rpt_test" a workbook, worksheet or range?
Rgds
Richard Buttrey
If this was useful then please rate it appropriately.
Click the small star iconat the bottom left of my post.
Hi adgjqetuo,
Here are the VBA DoCmd codes you could use if you went with two buttons:
To view the report:
To export the report to a file:Code:DoCmd.OpenReport "rpt_Test", acViewNormal, acPreview
Cheers,Code:DoCmd.OutputTo ObjectType:=acOutputReport, _ ObjectName:="rpt_Test", _ OutputFormat:=acFormatXLS, _ OutputFile:="S:\Testing\TestReport.xls", _ AutoStart:=True
Docendo discimus.
Please consider:
- Thanking those who helped you. Click the reputation icon
in the contributor's post and add Reputation.
- Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.
Thanks for the response! The export code works perfectly only it opens the excel file too. I want it to export "behind the scenes" and not actually open - just save. I tried turning off notifications but that didn't work. Any ideas?
Would turning auto start to "false" do the trick? I didn't think to try that earlier.
Also, what's the access vb code for yes no message box? Is it the same as excel?
IE:
if msgbox ("test", vb yesno) = vbyes then
<code>
else
<code>
end if
Last edited by adgjqetuo; 11-19-2009 at 02:20 AM.
Hi adgjqetuo,
Try changing:
AutoStart:=True
to:
AutoStart:=False
Cheers,
Docendo discimus.
Please consider:
- Thanking those who helped you. Click the reputation icon
in the contributor's post and add Reputation.
- Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.
Hi adgjqetuo,
You can use a MsgBox using the syntax described here:
MsgBox
But you may prefer to build your own form for this purpose.
Cheers,
Docendo discimus.
Please consider:
- Thanking those who helped you. Click the reputation icon
in the contributor's post and add Reputation.
- Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.
The codes you provided worked perfectly!
The msgbox I coded above worked fine. (I'm an excel guy and wasn't sure if that code was interchangable. but apparently it is)
Thank you!!!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks