Hi,
I have a continuous form with a command button.
I'm trying to write a command to open another form containing the main form, a subform, and a subsubform and access the record represented by
ID_MainForm > ID_SubForm > ID_SubSubForm
Here is my code:
When I click the command button and ID_SubSubForm belongs to the first ID_SubForm, everything is as I would like.
However, when ID_SubSubForm belongs to the next ID_SubForm, the ID_MainForm form opens (correct) and the subform with the FIRST ID_SubForm record (incorrect) and the SubSubForm with the NEW empty record (incorrect).
Could someone help modify the posted code?
I have a continuous form with a command button.
I'm trying to write a command to open another form containing the main form, a subform, and a subsubform and access the record represented by
ID_MainForm > ID_SubForm > ID_SubSubForm
Here is my code:
Code:
Private Sub cmd158_Click()
Dim strMainForm As String
Dim strSubForm As String
Dim strSubSubForm As String
Dim strMainCriteria As String
Dim strSubCriteria As String
Dim strSubSubCriteria As String
strMainForm = "MainForm"
strSubForm = "SubForm"
strSubSubForm = "SubSubForm"
strMainCriteria = "[ID_MainForm] =" & Me.[Tekst166] 'Tekst166 = ID_MainForm
strSubCriteria = "[ID_SubForm]= " & Me.[Tekst174] 'Tekst174=ID_SubForm
strSubSubCriteria = "[ID_SubSubForm]=" & Me.[Tekst175] 'Tekst175=ID_SubSubForm
DoCmd.OpenForm strMainForm, , , strMainCriteria
With Forms(strMainForm).Controls(strSubForm).Controls(strSubSubForm)
.Form.filter = strSubSubCriteria
.Form.FilterOn = True
End With
End Sub
When I click the command button and ID_SubSubForm belongs to the first ID_SubForm, everything is as I would like.
However, when ID_SubSubForm belongs to the next ID_SubForm, the ID_MainForm form opens (correct) and the subform with the FIRST ID_SubForm record (incorrect) and the SubSubForm with the NEW empty record (incorrect).
Could someone help modify the posted code?
Last edited by a moderator: