G
Guest
I have 4 forms, one is the main form, two are forms that open on occasion,
and the last is a navigation form with buttons such as "New Job", "Print
Job", "Open Customers Form", etc.
I am trying to set up the "Job Work Orders Form" button to close either of
the other two forms IF they are open. How do I set up my If/Then statement
to do this?
I got it to work, but if the forms aren't open, then I get an error.
Private Sub Open_Job_Work_Orders_Form_Click()
On Error GoTo Err_Job_Work_Orders_Form_Click
Forms("Customers Form").SetFocus
DoCmd.Close
Forms("Insurance Companies Form").SetFocus
DoCmd.Close
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Job Work Orders Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Job_Work_Orders_Form_Click:
Exit Sub
Err_Job_Work_Orders_Form_Click:
MsgBox Err.Description
Resume Exit_Job_Work_Orders_Form_Click
End Sub
and the last is a navigation form with buttons such as "New Job", "Print
Job", "Open Customers Form", etc.
I am trying to set up the "Job Work Orders Form" button to close either of
the other two forms IF they are open. How do I set up my If/Then statement
to do this?
I got it to work, but if the forms aren't open, then I get an error.
Private Sub Open_Job_Work_Orders_Form_Click()
On Error GoTo Err_Job_Work_Orders_Form_Click
Forms("Customers Form").SetFocus
DoCmd.Close
Forms("Insurance Companies Form").SetFocus
DoCmd.Close
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Job Work Orders Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Job_Work_Orders_Form_Click:
Exit Sub
Err_Job_Work_Orders_Form_Click:
MsgBox Err.Description
Resume Exit_Job_Work_Orders_Form_Click
End Sub