Previewing a report

G

Guest

Dear Sirs,
I have three reports which I would like to preview before printing.
I did the following code for the command button:
Private Sub Command65_Click()
On Error GoTo Err_Command65_Click

Dim stDocName As String

stDocName = "endofmonthstatementbie30preport"
DoCmd.OpenReport stDocName, acPreview
stDocName = "endofmonthstatementbie30"
DoCmd.OpenReport stDocName, acPreview
stDocName = "endofmonthstatementclientsnonpoolPDF"
DoCmd.OpenReport stDocName, acPreview

Exit_Command65_Click:
Exit Sub

Err_Command65_Click:
MsgBox Err.Description
Resume Exit_Command65_Click

End Sub

It's working, but the preview is opening behind my main switchboard. It
should open over the main switchbord like a pop-up.
Can someone tell me how to change the code?
Thanks
Klaus
 
A

Arvin Meyer [MVP]

Change the popup property of the switchboard form, or close it when running
the reports. You can do that by adding:

DoCmd.Close Me.Name

just before the exit label. Open the switchboard back up as you close one of
the reports.
 
G

Guest

Hi

The standard code would be
DoCmd.OpenReport "ReportName", acViewPreview, , , acDialog

So change you code to something like this

DoCmd.OpenReport stDocName, acDialog
stDocName = "endofmonthstatementbie30"
DoCmd.OpenReport stDocName, acDialog
stDocName = "endofmonthstatementclientsnonpoolPDF"
DoCmd.OpenReport stDocName, acDialog

Hope this helps
 
G

Guest

Sorry, did not understand correctly.
Maybe I explained wrong. So, once more.
I have a databse with has a main switchboard form with all command buttons
and an input form.
I tried not to see the whole program so-with I created this Main switchboard
form as a pop-up. If I would like to see a preview of my reports they are not
opening over the Main switchboard form - but behind .
If I take the pop-up function out of my main switchboard the Preview
function is correct - but actually what I am trying to do is a preview form
pop-up over the main switchboard pop-up.
I tried ti change the code as you said but I get the error message : Type
mismatch - but anyway, I don't want to close the main switchboard and reopen
it again.
Is it not possible to get the preview like a pop-up over a pop-up?
Thanks
Klaus
 
G

Guest

Hi Wayne
I changed it into:

Private Sub Command65_Click()
On Error GoTo Err_Command65_Click

Dim stDocName As String

DoCmd.OpenReport stDocName, acDialog
stDocName = "endofmonthstatementbie30"
DoCmd.OpenReport stDocName, acDialog
stDocName = "endofmonthstatementclientsnonpool"
DoCmd.OpenReport stDocName, acDialog
stDocName = "endofmonthstatementbie30preport"

Exit_Command65_Click:
Exit Sub

Err_Command65_Click:
MsgBox Err.Description
Resume Exit_Command65_Click

End Sub

Now I get an error message: The action or methods requires a report name
argument.
Can you please be as kind as to tell me what I did wrong?
Thanks
Klaus
 
G

Guest

Hi

If it were me I would simplify the code to

Private Sub Command65_Click()

DoCmd.OpenReport "endofmonthstatementbie30", acViewPreview, "", "",
acDialog

DoCmd.OpenReport "endofmonthstatementclientsnonpool", acViewPreview, "",
"", acDialog

DoCmd.OpenReport "endofmonthstatementbie30preport", acViewPreview, "",
"", acDialog

End Sub


All the above assumes that you have reports called;
endofmonthstatementbie30
endofmonthstatementclientsnonpool
endofmonthstatementbie30preport

And that you have (as per your code) a button called Command65


If you want the add Arvin's idea of closeing the form when you preview the
form your would need to add

DoCmd.Close acForm, "FormName"

I would never advise against using any advice from an MVP but my "non
expert" thoughts would be that if you close the form in the same code as
opening the reports you would need to re-open the form (OnClose) when you
have finished with the report. This would have the effect of opening the
form whenever you closed any other reports. Assuming that is what you want
to happen add the one line of closed at the end if not just run it as I have
shown.
 
A

Arvin Meyer [MVP]

stDocName is after the OpenReport, instead of before it. On the second 2,
there is a value and they would run the wrong report, but the first one has
no value for stDocName, so you are erroring out before the first OpenReport
action.
 
A

Arvin Meyer [MVP]

Is it not possible to get the preview like a pop-up over a pop-up?

Reports, at least in Access 2002 and later, also have a popup mode which can
be set, the same as for forms. In code you can open in Dialog mode, but that
may limit you to having to close the first report, before the second opens.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Acrobat Distiller 1
Opening PDF link in Access 1
Printing report to PDF file 5
preview a report 5
Is this exceptable? 1
Opening a Filtered Report from a Form Button 3
Report printing 1
Is this Command wrong! 1

Top