I’m using the following code to open a form in another database.
The problem is I want to run the code below in a form1 in database1 ,close the form1 in database1, quit database 1, and let some other code run in the database 2 on frmTest, and finally close and quit the database 2 when the code in frmTest is finished.
The code opens the frmTest in database 2, and closes database 2 using the docmd.quit line but I get error code 2501 “The Openform action was canceled” for line objaccess.docmd.openform “frmtest” in database 1.
I’ve tried to capture and ignore the error message but that didn’t work as I think the second database is still in control …just a guess?

Public Function OpenSameDayTq500()
On Error GoTo Err_Handler

Dim objAccess As Access.Application
Const conPATH = "\\PGB.COM\APPLICATIONS\trustdb\SameDayTQ.MDB"

'Create an instance of the Access application object.
Set objAccess = CreateObject("Access.Application")

objAccess.OpenCurrentDatabase conPATH
objAccess.Visible = True

'Open the frmTest
objAccess.DoCmd.OpenForm "frmtest"

' Maximize other Access window and quit current application.
objAccess.DoCmd.RunCommand acCmdAppMaximize

Exit Function
Select Case Err.Number
Case 2501
Resume Next
End Select

End Function