I have a main form [frm_Main1] which has owner/operator information. I have several buttons on the main form, that users can click on to bring up a subform. On one of the subforms [frm_Truck], it houses Truck #'s and information regarding the truck, and it ties to the Owner/Operator on the main form. I have set up search buttons on the main form to be able to search by last name, or search by a driver.
What I am attempting to do, is set up a combo-box (I would prefer a command button) that will search on the Truck # from the Main form, and then bring up the corresponding record that is associated it. Meaning, Click on button on Main form, type in Truck #, and it will bring up the record that is associated with that Truck # (meaning it will show the Owner/Operator that is associated).
I found some code that uses a combo-box (that's why I mentioned it), but I keep getting errors when I try to run it.
Code:
Private Sub Combo147_AfterUpdate()
Dim CBx As ComboBox, sfrm As Form, Cri As String
Set CBx = Me!Combo147
Set sfrm = [frm_Truck].Form
Cri = "[EmployeeID] = '" & CBx.Column(0) & "'"
Me.Recordset.FindFirst Cri 'Goto Employee
Cri = "[TruckNo] = '" & CBx.Column(1) & "'"
sfrm.Recordset.FindFirst Cri 'Goto weapon SN
Set sfrm = Nothing
Set CBx = Nothing
End Sub
[EmployeeID] is the relationship between the 2 forms. (frm_Main1, frm_Truck). [TruckNo] is the field in the [frm_Truck] which I'm trying to search on from the main form to bring up the record it's associated with.
Can anyone help with this code, or help change the code to work with a command button?
Thanks!