Originally Posted by
hertfordkc
Forms![A].visible = no
Forms![C].visible = no
Docmd.Opernform "B", parameters
A bit off (but understandable if you don't have something to test with).
Forms!A.Visible = FALSE
Forms!C.Visible = FALSE
DoCmd.OpenForm "B", acNormal
but a simpler way is to create a function:
Code:
Function OpenForm(strFormNameHere)
Dim frm As Form
For Each frm in CurrentProject.AllForms
If frm.Name = strFormNameHere Then
If CurrentProject.AllForms(frm.Name).IsLoaded = False Then
DoCmd.OpenForm frm.Name, acNormal
Else
frm.Visible = True
End If
Else
frm.Visible = False
End If
Next
End Function
Then just call your function from the button's click event and pass the appropriate form name you want to be displayed.
In Button A you would use
or for Button B
Which would open the form designated and hide all others.