Report Preview

A

Amateur

I'm trying to preview a report from DB1 in DB2 with help of a coomand button.
This I did so far:
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
 
O

Ofer Cohen

from the button you are calling OpenSalesPersonalCommission
and the name of the sub is OpenCommissionReport

The names are different and this is why it can't find it
 
A

Amateur

Hi Ofer
I tried severals ways before and now I changed it to like you said (the
result is the same as before) Any other idea?:

***********************
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()
OpenCommissionReport
End Sub
*****************************
Thanks
Klaus
 
O

Ofer Cohen

Hi Klaus

Change the name of the button, not to have the same name as the sub

After the changes are made, just in case, close bothe MDB's.
Check the reference again, mybe it say missing next to one of them,
myebe the reference to the mdb doesn't exist

It should work with the sub or function.
 

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


Top