Below is code I wrote to try and allow the user to search all records for a Part Number and then go to the record that has that number.
I have a combo box on the main form that is unbound but gets its data from the same record source as the sub-subform. The user picks a part from the combobox then presses the Part button.The code works the 1st time and usually more than once. It almost seems as though as long as its searching forward it finds and moves to the correct record, but if you try to go backwards its just finds the customer and the first record for that customer. Does anyone see a issue that sticks out?
Code:
Private Sub cmdPartSearch_Click()
Dim frm As Form
Set frm = Forms!Main.Form!Molds.Form
Dim Cust, lngMold, lngPart As Long
Cust = Me.cboPartSearch.Column(2)
lngMold = Me.cboPartSearch.Column(3)
lngPart = Me.cboPartSearch.Column(0)
MsgBox Cust & " " & lngMold & " " & lngPart
CustomerID.SetFocus
DoCmd.FindRecord FindWhat:=Cust, Match:=acEntire, MatchCase:=False, _
Search:=acSearchAll, SearchAsFormatted:=False, _
OnlyCurrentField:=acCurrent, FindFirst:=True
Forms.Main.Molds.SetFocus
DoCmd.FindRecord FindWhat:=lngMold, Match:=acEntire, MatchCase:=False, _
Search:=acSearchAll, SearchAsFormatted:=False, _
OnlyCurrentField:=acCurrent, FindFirst:=True
frm.Parts.SetFocus
DoCmd.FindRecord FindWhat:=lngPart, Match:=acEntire, MatchCase:=False, _
Search:=acSearchAll, SearchAsFormatted:=False, _
OnlyCurrentField:=acCurrent, FindFirst:=True
CustomerID.SetFocus
Me.cboPartSearch = Null
Set frm = Nothing
Me.Repaint
End Sub