Call report from different database

  • Thread starter Thread starter Dale
  • Start date Start date
D

Dale

Hello
I have an Access2K database that automatically prints a set of reports
initiated by the user from a form after importing monthly data. To complete
the report package, one other report resides in a different database (also
Access2K). Is it possible to make a call to an external database to print
this other report without having linked the two databases?

Thanks for your help
 
Dale said:
I have an Access2K database that automatically prints a set of reports
initiated by the user from a form after importing monthly data. To complete
the report package, one other report resides in a different database (also
Access2K). Is it possible to make a call to an external database to print
this other report without having linked the two databases?


You can only call a procedure in another database if you set
a Reference to the other database and create a procedure to
call.

It would probably(?) be easier to use Automation to open the
other database and use its application's methods.

Public Sub RunReport()
Dim app As Access.Application

Set app = CreateObject("Access.Application")
app.OpenCurrentDatabase ("D:\Clients\MyExamples XP.MDB")
app.Visible = True

app.DoCmd.OpenReport "My Report", acViewPreview

End Sub
 
Hi Dale,

try this:

'--------- testReportInOtherDatabase
Sub testReportInOtherDatabase()
ReportInOtherDatabase _
"C:\path\test.mdb", "ReportName"
End Sub

'--------- ReportInOtherDatabase
Sub ReportInOtherDatabase( _
ByVal pDBfile As String, _
ByVal pReport As String)

'PARAMETERS
'pDBfile --> full path and filename of the database
'pReport --> name of the report

On Error GoTo err_proc

'when I write code, I use this:
' Dim accApp As Access.Application
'when I run, I use this:
Dim accApp As Object

Set accApp = CreateObject("Access.Application")
accApp.OpenCurrentDatabase pDBfile

accApp.Visible = True
accApp.DoCmd.OpenReport "temp", acViewPreview
MsgBox "click OK to continue", , "OK to continue"

exit_proc:
On Error Resume Next
accApp.Quit
Set accApp = Nothing
Exit Sub

err_proc:
MsgBox Err.Description, , "ERROR " & Err.Number _
& " ReportInOtherDatabase"
Stop
Resume

Resume exit_proc

End Sub
'----------------------------------

Warm Regards,
Crystal
MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
Hi Dale,

sorry, I wrote this a bit fast...

change

accApp.DoCmd.OpenReport "temp", acViewPreview

to

accApp.DoCmd.OpenReport pReport, acViewPreview

on the error handler:

change
Stop
Resume

Resume exit_proc


to

'press F8 to step thru code and fix problem
'comment next 2 lines after debugged
Stop
Resume

Resume exit_proc


Warm Regards,
Crystal
MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
Thanks Crystal..worked like a charm...
Dale

strive4peace said:
Hi Dale,

sorry, I wrote this a bit fast...

change

accApp.DoCmd.OpenReport "temp", acViewPreview

to

accApp.DoCmd.OpenReport pReport, acViewPreview

on the error handler:

change
Stop
Resume

Resume exit_proc


to

'press F8 to step thru code and fix problem
'comment next 2 lines after debugged
Stop
Resume

Resume exit_proc


Warm Regards,
Crystal
MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
you're welcome, Dale ;) happy to help

Warm Regards,
Crystal
MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
Back
Top