Open Report in External Database 
Author Message
 Open Report in External Database

Hi,

VBA novice here... I've been trying (with no success) to
get this to work. What is the proper code to open up a
report that is located in a different database? So far,
I've got the following:

Private Sub cmdRptClientStat_Click()
    Dim db as Database

    Set db = DBEngine.Workspaces(0).OpenDatabase
("j:\ClientDB.mdb" _
    , , True)

    '[Some code goes here to view the report.]

    db.Close
    Set db = Nothing

End Sub

Do I need to somehow set db as the current database and
then use DoCmd.OpenReport?

Or do I have to re-create the report in the current
database and connect it to the external database? Any help
would be greatly appreciated.

James



Tue, 13 Dec 2005 04:03:33 GMT  
 Open Report in External Database

Quote:

> What is the proper code to open up a
>report that is located in a different database?

One way is to add a reference to the other db as a library.
Then add a Public procedure in a standard module in the
other db that executes the OpenReport method.  

Quote:
>Or do I have to re-create the report in the current
>database and connect it to the external database?

No, you don't have to do that.

Another way to perform actions in another db is to use
Automation to open another instance of Access with the other
db.

Check out those concepts in Help and post back with a more
specific question if you need more help.

--
Marsh
MVP [MS Access]



Tue, 13 Dec 2005 07:04:08 GMT  
 Open Report in External Database

Thanks, Marshall. Adding the reference did the trick.

Quote:
>-----Original Message-----

>> What is the proper code to open up a
>>report that is located in a different database?

>One way is to add a reference to the other db as a
library.
>Then add a Public procedure in a standard module in the
>other db that executes the OpenReport method.  

>>Or do I have to re-create the report in the current
>>database and connect it to the external database?

>No, you don't have to do that.

>Another way to perform actions in another db is to use
>Automation to open another instance of Access with the
other
>db.

>Check out those concepts in Help and post back with a more
>specific question if you need more help.

>--
>Marsh
>MVP [MS Access]
>.



Tue, 13 Dec 2005 23:43:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. External database VS. OCBC database...?????

2. ODBC database .vs. External database

3. Access 2.0/Crystal Reports 4.0 - Can't Open Database Error

4. Crystal Reports "Unable to open database"

5. Crystal Report can not open database

6. How to open crystal report in VB which the acces database contains password

7. Crystal Report "unable to open database"

8. Crystal Reports Error - Unable to Open database

9. Print/View Access Report from within VB (with database open)

10. Error 20533 (unable to open Database) in Crystal Reports

11. Changing a report that uses 1 database into a report using 2 databases

12. using a value in a table field to open an external program

 

 
Powered by phpBB® Forum Software