Why toggle buttons? Seems these should just be command buttons.
Sounds like you are trying to emulate a Navigation Form.
Just as FYI, in case you were interested. Here's a screenshot of what I was talking about earlier. Each tab presents a different set of questions.
View attachment 98223
I like the format of the image you have included. I would like to know how you set this up. It looks like it would work for me.
Here is the VBA code that is produced through the wizard.
Form_Current_Exit:
Exit Sub
Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit
End Sub
Sub ToggleLink_Click()
On Error GoTo ToggleLink_Click_Err
If ChildFormIsOpen() Then
CloseChildForm
Else
OpenChildForm
FilterChildForm
End If
ToggleLink_Click_Exit:
Exit Sub
ToggleLink_Click_Err:
MsgBox Error$
Resume ToggleLink_Click_Exit
End Sub
Private Sub FilterChildForm()
If Me.NewRecord Then
Forms![InspGeneralT].DataEntry = True
Else
Forms![InspGeneralT].Filter = "[InspDetails] = " & Me.[InspDetID]
Forms![InspGeneralT].FilterOn = True
End If
End Sub
Private Sub OpenChildForm()
DoCmd.OpenForm "InspGeneralT"
If Not Me.[ToggleLink] Then Me![ToggleLink] = True
End Sub
Private Sub CloseChildForm()
DoCmd.Close acForm, "InspGeneralT"
If Me![ToggleLink] Then Me![ToggleLink] = False
End Sub
Private Function ChildFormIsOpen()
ChildFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "InspGeneralT") And acObjStateOpen) <> False
End Function
I would like to have several buttons on the top to add different entries that are linked to the main form Inspection Details. If I create another button and point the event to a different form it gives me errors.