Forum Statistics
- Forum Members:
- Total Threads:
- Total Posts: 7
There are 1 users currently browsing forums.
|
 |

11-18-2009, 11:41 AM
|
|
Registered User
|
|
Join Date: 06 Aug 2007
Posts: 87
|
|
|
View Report (With Excel) - vba code?
Please Register to Remove these Ads
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 07:49 AM.
|

11-18-2009, 11:48 AM
|
 |
Forum Moderator
|
|
Join Date: 15 Feb 2008
Location: Grappenhall, UK
MS Office Version:Excel for Windows 2003, 2007, for Mac 2004, 2008
Posts: 3,351
|
|
|
Re: View Report (With Excel) - vba code?
Hi,
Is "rpt_test" a workbook, worksheet or range?
Rgds
__________________
Richard Buttrey
If this was useful then please rate it appropriately.
Click the balance scales icon  in the grey (or gray if you inhabit our former colony across the pond  ) bar at the top of my post.
|

11-18-2009, 12:54 PM
|
 |
Valued Forum Contributor
|
|
Join Date: 11 Mar 2009
Location: Victoria, Canada
MS Office Version:2003
Posts: 576
|
|
|
Re: View Report (With Excel) - vba code?
Hi adgjqetuo,
Here are the VBA DoCmd codes you could use if you went with two buttons:
To view the report:
Code:
DoCmd.OpenReport "rpt_Test", acViewNormal, acPreview
To export the report to a file:
Code:
DoCmd.OutputTo ObjectType:=acOutputReport, _
ObjectName:="rpt_Test", _
OutputFormat:=acFormatXLS, _
OutputFile:="S:\Testing\TestReport.xls", _
AutoStart:=True
Cheers,
__________________
Docendo discimus.
|

11-19-2009, 01:07 AM
|
|
Registered User
|
|
Join Date: 06 Aug 2007
Posts: 87
|
|
|
Re: View Report (With Excel) - vba code?
Quote:
Originally Posted by ConneXionLost
Hi adgjqetuo,
Here are the VBA DoCmd codes you could use if you went with two buttons:
To view the report:
Code:
DoCmd.OpenReport "rpt_Test", acViewNormal, acPreview
To export the report to a file:
Code:
DoCmd.OutputTo ObjectType:=acOutputReport, _
ObjectName:="rpt_Test", _
OutputFormat:=acFormatXLS, _
OutputFile:="S:\Testing\TestReport.xls", _
AutoStart:=True
Cheers,
|
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 01:20 AM.
|

11-19-2009, 01:15 AM
|
 |
Valued Forum Contributor
|
|
Join Date: 11 Mar 2009
Location: Victoria, Canada
MS Office Version:2003
Posts: 576
|
|
|
Re: View Report (With Excel) - vba code?
Hi adgjqetuo,
Try changing:
AutoStart:=True
to:
AutoStart:=False
Cheers,
__________________
Docendo discimus.
|

11-19-2009, 01:25 AM
|
 |
Valued Forum Contributor
|
|
Join Date: 11 Mar 2009
Location: Victoria, Canada
MS Office Version:2003
Posts: 576
|
|
|
Re: View Report (With Excel) - vba code?
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.
|

11-20-2009, 07:49 AM
|
|
Registered User
|
|
Join Date: 06 Aug 2007
Posts: 87
|
|
|
Re: View Report (With Excel) - vba code?
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!!!
|
 |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|