I have the following code that I use to open a database and print a report. However, I want the code to close the database once the report is printed. The current code for that step does not work. Any advice?
Private Sub Command16_Click()
Dim appAccess As Access.Application
fOpenRemoteReport2 "rptClassDetailsForDateRange", "K:\APPLICTN\Access\Training Database.mdb"
Function fOpenRemoteReport2(strReport As String, strMDB As String) As Boolean
If IsMissing(strMDB) _
Or Len(strMDB) = 0 Then
' Open form in current db
' Create new instance of Microsoft Access.
Set appAccess = _
' Open database in Microsoft Access window.
' Open required report from within the OTHER database.
' Close the database.
DoCmd.Close acDefault, strMDB, acSaveNo
Set appAccess = Nothing
Thanks ottomatic, but I think I left out an important detail. The database I am trying to close is an external database (where the report resides). The code opens an external database, prints the report and now I want to close that external database--not the one I am currently coding in, which is what DoCmd.Quit does. Any ideas?