Selecting Form record from SubForm

joltremari

Registered User.
Local time
Today, 20:46
Joined
Jun 4, 2001
Messages
24
I have a Form with SubForm1 and Subform2.
SubForm2 holds sub-records of SubForm1 - - - and SubForm1 holds sub-records of the main Form.

I would like to have a combo box to look up a record in SubForm1 and display the related records in the main Form and SubForm2

The tables in which the forms were made each have a relationship to each other.

Main Form ID --->related to ---> SubForm1-MainFormID

SubForm1 ID --->related to---> SubForm2-SubForm1ID


I hope I explained this clearly, that it can be understood.

Any help is appreciated.

JO
 
Just create the combo box containing the values (must be unique values) of the field in subform1-based table. Then on On_Update of the combo, use the code below to do the task.

Private Sub Combo0_AfterUpdate()
Dim I as Long ' (or Integer)
I =NZ(DFirst("ID","subform1-based table","[TheFieldYouWannaLookUp]='" & Me.Combo0 & "'"),0)
If I <>0 Then
Me.RecordsetClone.FindFirst "[ID] = " & I
Me.Bookmark = Me.RecordsetClone.Bookmark
Else
MsgBox "No record found"
Exit Sub
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom