Open Report in External Database

I

Ian King

Can anyone help with a bit of code to print reports from an external
database? The reports are unbound.

Many thanks

Ian King
 
A

Arvin Meyer [MVP]

You might try dragging the report from the database window to the desktop.
That will create a shortcut which will open the report for printing. You can
also set a reference to the database that has the report you want to open,
then write a standard module sub to open the report. You can now call that
sub for the first database. The code is the same as opening a report
normally, it's just put in a Standard Module:

Public Sub OpenContractors()
DoCmd.OpenReport "rptContractors", acPreview
End Sub

Then in the calling database, a single line in the click event of a button:

Sub OpenRpt_Click()
OpenContractors
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
I

Ian King

Love the add reference solution, - never tried that before. However, I need
to have references to several databases which have duplicate modules in (too
late to change). This will presumably throw wobblies if I try to reference
them all.

I've just tried experimenting with the application object and
OpenCurrentDatabase method which seems to work ok - are there any pitfalls
in using this method when you already have a database open?

Many thanks

Ian King
 
A

Arvin Meyer [MVP]

Other than possible record-locking violations, there shouldn't be any
problem. Beware of locking violations though, because accessing and
application in code doesn't lock in the same way. Make sure that you have
good error handling that is verbose, so that you will know if there's a
problem.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 

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

Top