open report button does not work

smile

Registered User.
Local time
Today, 07:49
Joined
Apr 21, 2006
Messages
212
I use access 2007 designed blank form and added command button, then selected report operation -> open report selected my report.

When I open the form and click the button nothing happens however if I add preview report it works why?
 
If you don't specify preview the default is printing out to the default printer. Might that be what it's doing?
 
If you don't specify preview the default is printing out to the default printer. Might that be what it's doing?

No it nor doing anything, and not printing that is for sure. I would see canon printer popup that would show my document is printing. I have added my database path to trusted location etc.

Please help.
 
What is the code behind the button that works and the code that doesn't work? What is the default printer on the PC?
 
What is the code behind the button that works and the code that doesn't work? What is the default printer on the PC?

Default printer: Canon Pixma 6600D,

Open reprot button - that does not work

PHP:
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click


    stDocName = "___pagrindinis_pvm"
    

Exit_Command0_Click:
    Exit Sub

Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click
    
End Sub

Print Preview button - that works

PHP:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

    Dim stDocName As String

    stDocName = "___pagrindinis_pvm"
    DoCmd.OpenReport stDocName, acPreview

Exit_Command1_Click:
    Exit Sub

Err_Command1_Click:
    MsgBox Err.Description
    Resume Exit_Command1_Click
    
End Sub
 
You don't have any command to open the report in the one that doesn't work! All

stDocName = "___pagrindinis_pvm"

does is assign the report name to the variable! You have to follow it with

DoCmd.OpenReport stDocName

for the report to be opened and printed!
 
Last edited:
The print preview has the line of DoCmd.OpenReport stDocName, acPreview, therefore the preview of the report works. But, in the code you show for the actual printing of the report, there is no line to open the report. You can add a line that is like this:
DoCmd.OpenReport stDocName, acNormal
You should also add a line like this:
Dim stDocName As String
Use the code for the Preview of the report to see where to add the lines for the actual printing of the report. Except for the acNormal or acPreview, the two sets of code should look the same.
 
Since this obviously is command button wizard generated code, you must have accidentally deleted the code to print the report!
 
Since this obviously is command button wizard generated code, you must have accidentally deleted the code to print the report!

No I did not delete anything, this is default code from wizard.
Weird but perhaps access 2007 has bug or something?
 
It'd be worth running up a test form and recreating the button to see if it's a bug!
 
Smile,
Is the code working now?

The code you posted is working it is printing the report to the printer without preview or epening the report.

But I need to open the report not sent it to print. That is why I create "Open Report" button but it does not work made with the wizard.
 
If you want to preview the report, then the second one you tried is the one you want. Use the acPreview option rather than the acNormal option. OpenReport, if you read the documentation (the online help file) explains what these options do for you. OpenReport opens the report to either the screen (acPreview) or to the printer (acNormal).
 
If you want to preview the report, then the second one you tried is the one you want. Use the acPreview option rather than the acNormal option. OpenReport, if you read the documentation (the online help file) explains what these options do for you. OpenReport opens the report to either the screen (acPreview) or to the printer (acNormal).

Thanks, for your help everyone
 

Users who are viewing this thread

Back
Top Bottom