Open Report in External Database

  • Thread starter Thread starter Ian King
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top