Previewing a report

  • Thread starter Thread starter Amateur
  • Start date Start date
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
 
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.
 
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
 
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.
 
Back
Top