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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching by multiple parameters?

Status
Not open for further replies.

longTommy

Technical User
Dec 19, 2006
9
US
Hey all.
(Access 2003)

I've been trying to figure out how I can create a button within my form that will search a table by two different columns.

The jist of it is:

A form called "ItemMasterSearch" that I want to have a text box that I can type in a vendor part number or manufacturer part number and it will search in my "QVL" table under the respective fields and return the search in a subform.

I've come to the point that i can get it to search by one parameter, but it's not what i want it to do. i've seen it done many times before, but haven't been able to put a finger on how it's done.

Thanks for all of the info that everyone has already put on the site. it's fantastic!!

Tommy
 
Hello,

You probably tried this, but you could try putting the second field criteria in the OR part of the query builder.

Should work if I understand you correctly.



SG
 
if you put in the or it should work like SG suggests

I will try my best to help others so will others do!!!!!
IGPCS
Brooklyn, NY
 
I edited my query but it doesn't do what i want it to do then.

I guess i should explain my setup a little more.

Text Box (1)
Name: ItemLookUP

Command Button (1)
Name: ItemFind

Subform (1)
Name: Sub

Query (1)
Name: ItemMasterLooky

I think my problem is in linking the the text box or something like that, but it could be in my command button.

Here is the code for my button:

Code:
Private Sub ItemFind_Click()
  Dim strLookUp As String
  
    'Doesn't look up by mfr or vendor id, but by the ProductID
  
  On Error GoTo Err_Sub
  If Not IsNull([ItemLookUp]) Then
    'ProductID.SetFocus
    'Me.autoid.SetFocus
    strLookUp = StringReplaceBadBadCharsInFindRecord(ItemLookUp)
    'MsgBox strLookUp 'debug code
    Me.Sub.SetFocus
    DoCmd.FindRecord (strLookUp) '([ItemLookUp])
    ItemLookUp.SetFocus
  Else
    MsgBox "Please enter a product to go to."
  End If
Exit_Sub:
    Exit Sub
Err_Sub:
    If (Err.Number = 3058 And Me.NewRecord) Then '3058 -> NULL Primary key not allowed, started new record then decided to goto another
      MsgBox "ItemID cannot be blank.  To cancel creating/editing current record, press 'Esc' then go to another record with navigation buttons at bottom.  Then use lookup.", vbCritical, "NULL ItemID"
    Else
      MsgBox "Error " & Err.Number & ": " & Err.Description
    End If
    Resume Next
End Sub
 
is there a way i can put two parameters in the control source for my text box or do i need to go about it another way?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top