Open form based on condition

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
 
A

Andy Cole

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top