Solved How to show relevant record to subform using combo box from main form

rehanemis

Registered User.
Local time
Today, 17:39
Joined
Apr 7, 2014
Messages
195
Hi,
I have main form with subform. I would like to show relevant record after choosing value from combo-box. The matching field type is text.
type mismatch.JPG
 
Is it really a subform? If so, you should be able to link the main form with the subform by using the Linked Master and Child Fields to display the related records in the subform.
 
The
Is it really a subform? If so, you should be able to link the main form with the subform by using the Linked Master and Child Fields to display the related records in the subform.
Main form doesn't having the fields linked with master / parent.
 
The

Main form doesn't having the fields linked with master / parent.
So, is it an unbound main form then? Even still, you could link the subform using a Textbox or Combobox on the main form.
 
how can I? Please share.
Just use the Linked Master and Child Fields properties. Try entering the name of the Combobox as Master and the Field's name as the Child.
 
add code to the Combobox AfterUpdate event:

Code:
Private Sub comboName_AfterUpdate()
If Me.comboName.ListIndex > -1 Then
    'valid value from combobox
    With Me.RecordsetClone
        .FindFirst "[Employee ID] = " & Chr(34) & Me.comboName & Chr(34)
        Me.Bookmark = .Bookmark
    End With
End If
End Sub

replace comboName with the name of your combo.
 
As DBGuy said. Assume the combo box name is cmboEmpID and the subform field is empID. Then the properties look like

Link Master Fields: [cmboEmpID]
Link Child Fields: [EmpID]

no code required.
 

Users who are viewing this thread

Back
Top Bottom