Button won't Open Report.

vwgolfman

Registered User.
Local time
Today, 11:31
Joined
May 26, 2008
Messages
35
Hi I am using MS Access 2007.
I have 1 simple report.
I have 1 simple Form.

I wish to place a button on the form which opens the report.
When the button wizard runs, I choose "Open report" and select the report I wish to open.
When I run the form and click the button nothing happens.

If I place another button and select "Preview report" in the wizard then the button works (but I don't want to open the report in Preview mode).

Please can anybody help me to "Open Report" using my button?

Thank you
 
You do realize that if you are selecting Open report that it goes straight to the printer and does not open for viewing. You need preview if you want to actually view it.
 
Hi Bob.

I wanted the report to open and look like it does in "Report View" rather than "Print Preview" view.

How do I do this please?
 
In 2007 that code is:

DoCmd.OpenReport "YourReportNameHere", acViewReport
 
Here is the code which is generated by the wizard for "Open Report"...

Option Compare Database
Private Sub ButtonOne_Click()
On Error GoTo Err_ButtonOne_Click

stDocName = "Report1"

Exit_ButtonOne_Click:
Exit Sub
Err_ButtonOne_Click:
MsgBox Err.Description
Resume Exit_ButtonOne_Click

End Sub

_____________________

.....and here is the code generated by the wizard for "Preview Report"...

Private Sub ButtonTwo_Click()
On Error GoTo Err_ButtonTwo_Click
Dim stDocName As String
stDocName = "Report1"
DoCmd.OpenReport stDocName, acPreview
Exit_ButtonTwo_Click:
Exit Sub
Err_ButtonTwo_Click:
MsgBox Err.Description
Resume Exit_ButtonTwo_Click

End Sub

____________

You can see that the first code does not actually do anything.
Is this a bug?
 
If that's actually what the wizard produced, then yes. It did not put in the most important line, the one Bob posted. Add that with the appropriate name and see if it works for you.
 
I'm amazed that the wizard would create that because whatever I try the wizard (in 2007) produces an Embedded Macro and not VBA code.
 
I'm sorry, I did beat around the bush. I was going to say I hated it, but toned it down. :p
 

Users who are viewing this thread

Back
Top Bottom