Previewing a report

A

Amateur

I am trying, with a commnd button in DB1, to preview a report from a DB2.
I did the following:
I created in DB2 (the one with the report) a Macro - Echo, set warnings,
Open report (in preview), Quit

I use the following code for my command button in DB1:
******************************************
Private Sub preview_Click()
Call Shell("""C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE""
""C:\cps208\sales.mdb""/Xpreviewcommission ", 0)
End Sub
******************************************
I did the same to print the the report and its working fine - why is it not
working if I only want to preview the report?
Can someone help?

Thanks
Klaus
 
A

Arvin Meyer [MVP]

You can set a reference to DB2 in DB1 and write a routine in a DB2 standard
module to open the report like:

Public Sub OpenCommissionReport()
DoCmd.OpenReport "rptWhatever", acViewPreview
End Sub

Then in DB1, you set the reference to DB2 and create command button code
like:

Private Sub cmdOpenReport_Click()
OpenCommissionReport
End Sub

Then you can do what you want.
 
A

Amateur

Hi Arvin

I created the Reference in DB1.

I created in DB 2 a Module like this:

**************************
Public Sub OpenCommissionReport()
DoCmd.OpenReport "salespersonalcommission", acViewPreview
End Sub
***************************

I use the following code for my command button in DB 1

****************************
Private Sub OpenCommissionReport_Click()
OpenSalesPersonalCommission
End Sub
*****************************

I alwauys get the error message "Sub or Function not defined" - Can you tell
me what I did wrong?
Thanks
Klaus
 
F

fredg

Hi Arvin

I created the Reference in DB1.

I created in DB 2 a Module like this:

**************************
Public Sub OpenCommissionReport()
DoCmd.OpenReport "salespersonalcommission", acViewPreview
End Sub
***************************

I use the following code for my command button in DB 1

****************************
Private Sub OpenCommissionReport_Click()
OpenSalesPersonalCommission
End Sub
*****************************

I alwauys get the error message "Sub or Function not defined" - Can you tell
me what I did wrong?
Thanks
Klaus

You changed Arvin's suggested code.
You are calling the
OpenSalesPersonalCommission
sub, which doesn't exist since you named the sub
OpenCommissionReport

Change the Command button click event code in Db1 to:

Private Sub cmdOpenReport_Click()
OpenCommissionReport
End Sub

which is what Arvin suggested.
 

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

Report Preview 3
Printing a report 2
Opening a Form 4
Opening a Form from a different database 9
Forms from two different .mbd files 1
Linked Tables 1
setting values to "0" 3
Previewing a report 7

Top