More than one toggle button in a form to open different subforms (1 Viewer)

KRBTFD

New member
Local time
Today, 10:26
Joined
Oct 30, 2018
Messages
4
I am creating a form for inspections and have a table with Inspection Details, which is general information such as date time, location etc. There are different sections such as Air Quality, water quality, etc. I have separate tables with the information listed. When using the form wizard I can create the main form with a toggle button to open the linked sub form and the coding is created and works well. I am trying to create another toggle button to open another linked subform just changing the reference form. It is giving me an error for the on load event that there is a conflict with the child form. Is there a way to code the onload to resolve this conflict. I guess the question is can I put more than one toggle button pointing to different sub forms a child forms on one main form?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 14:26
Joined
Feb 19, 2013
Messages
16,553
short answer is yes. but need to see your code to suggest what it might look like
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:26
Joined
Oct 29, 2018
Messages
21,357
Hi. Welcome to AWF!

I am creating a claims database for an insurance company and have decided to use a tab control, rather than a toggle button, to display the relevant questions for each category. Perhaps you could consider using that approach as well. Just a thought...
 

June7

AWF VIP
Local time
Today, 06:26
Joined
Mar 9, 2014
Messages
5,423
Why toggle buttons? Seems these should just be command buttons.

Sounds like you are trying to emulate a Navigation Form.
 

GPGeorge

Grover Park George
Local time
Today, 07:26
Joined
Nov 25, 2004
Messages
1,775
I am creating a form for inspections and have a table with Inspection Details, which is general information such as date time, location etc. There are different sections such as Air Quality, water quality, etc. I have separate tables with the information listed. When using the form wizard I can create the main form with a toggle button to open the linked sub form and the coding is created and works well. I am trying to create another toggle button to open another linked subform just changing the reference form. It is giving me an error for the on load event that there is a conflict with the child form. Is there a way to code the onload to resolve this conflict. I guess the question is can I put more than one toggle button pointing to different sub forms a child forms on one main form?
Perhaps I'm reading the wrong thing into your statement, but this sounds like the wrong path to me if I am interpreting correctly.
"...a toggle button to open the linked sub form...."

If you mean that there are two separate forms and the toggle button (or command button) opens one as a "sub form" independently of the form which has this button on it, then that's not very effective, IMO.

theDBGuy's approach sounds better to me. A tab control with three embedded subforms.
 

SHANEMAC51

Active member
Local time
Today, 17:26
Joined
Jan 28, 2022
Messages
310
There are different sections such as Air Quality, water quality, etc. I have separate tables with the information listed


therefore, they have their own data source - in this case, I use a form call by a button (or a line in the list) in a separate window

I use tabs only if there are too many fields (perhaps the table is not normalized) and the fields do not fit into the screen
 

KRBTFD

New member
Local time
Today, 10:26
Joined
Oct 30, 2018
Messages
4
short answer is yes. but need to see your code to suggest what it might look like
Thank you I am a novice at VBA and can't figure out the code that is generated by access. When I create the second button and copy the code what needs to be changed?
 

KRBTFD

New member
Local time
Today, 10:26
Joined
Oct 30, 2018
Messages
4
Thank you I am a novice at VBA and can't figure out the code that is generated by access. When I create the second button and copy the code what needs to be changed?
I will copy in the code from my computer and post it
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:26
Joined
Oct 29, 2018
Messages
21,357
I will copy in the code from my computer and post it
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.

1644775422122.png
 

KRBTFD

New member
Local time
Today, 10:26
Joined
Oct 30, 2018
Messages
4
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.
1644874382524.png

1644874417336.png
 

Users who are viewing this thread

Top Bottom