Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Combo Box look to two different fields? 1

Status
Not open for further replies.

Cristodul

Technical User
Mar 22, 2007
29
US
Hi everybody,

I have a combo box that I’m using it as a search for replaced part numbers. Right now combo box is searching only in the old part number field. Can I set up the combo box to search in new part numbers as well or I have to create a second combo box?

Thank you all!
 
What is the actual code of the AfterUpdate event procedure of the combo ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

Private Sub Search_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[OLD_PN] = '" & Me![Search] & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Please Enter a Valid Part Number"
End If
End Sub

 
You wanted something like this ?
Private Sub Search_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[OLD_PN] = '" & Me![Search] & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
rs.FindFirst "[NEW_PN] = '" & Me![Search] & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Please Enter a Valid Part Number"
End If
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You may also try this:
Private Sub Search_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "'" & Me![Search] & "' In ([OLD_PN],[NEW_PN])"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Please Enter a Valid Part Number"
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you so much for such a quick response and quick solution.
Both of the codes are returning the same results.

Great forum, but greater people!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top