Open form based on condition

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

Hi All,
I have an Order form and an Eqipment form I want the user
to be able to open Equipment form if and only if the order
form is open. I am not sure how to do this. Any
assistance would be greatly appreciated. Thanks.

Jim
 
Jim

If you're using A2K or higher you can use the AllForms collection to check
whether the Order form is open in the OnOpen event of the Equipment Form;

Private Sub Form_Open(Cancel As Integer)

If Not(CurrentDB.AllForms("frmOrders").IsLoaded) Then
DoCmd.Close acForm, Me.Name
End If

End Sub

In A97 you'll need to use the IsLoaded function code from the Northwind
sample DB and change the code to;

If Not(IsLoaded("frmOrders")) Then
DoCmd.Close acForm, Me.Name
End If

If preferred, instead of using the DoCmd.Close... you could set the OnOpen's
Cancel parameter to True but that will mean having to trap a 2501 error
(...last action was cancelled...)

HTH

Andy
 
Back
Top