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

Querydef with a wild card

Status
Not open for further replies.

thegameoflife

Programmer
Dec 5, 2001
206
0
0
US
How do i add a wild card search on txtprovname ???

Code:
where = Null
where = where & " AND [Member_Name] = '" + Me!txtmembername + "'"
where = where & " AND [Provider_Name] = '" + Me![txtprovname] + "'"
where = where & " AND [Member_Num] = '" + Me![txtmembernum] + "'"
where = where & " AND [Claim_Num] = '" + Me![txtclaim] + "'"
where = where & " AND [Tax_ID] = '" + Me![txtTaxid] + "'"
where = where & " AND [Provider_Num] = '" + Me![txtprovidernum] + "'"

Set QD = db.CreateQueryDef("Dynamic_Query", _
      "Select * from Tbl_Aus_History " & (" where " & Mid(where, 6) & ";"))

Me.Frm_Search_Subform.Form.RecordSource = "Dynamic_Query"
 
Hi,
To use the wildcard, use code similar to the following. In essence, you are replacing the equal sign with the keyword "like". And, if you are looking for any string embedded inside your textbox, then you need to encase the string in *'s:
Instead of this:
[Tax_ID] = '" + Me![txtTaxid]
Use this:
[Tax_ID] like '*" & Me![txtTaxid] & "*'"

Your string will look like this:
[Tax_ID] like '*234*'
This code will return all records that contain '234' anywhere inside the Tax_ID field. HTH,
Randy Smith
California Teachers Association
 
perfect... thank you

Code:
where = Null
where = where & " AND [Member_Name] = '" + Me!txtmembername + "'"
where = where & " AND [Provider_Name] Like '*" & Me![txtprovname] & "*'"
where = where & " AND [Member_Num] = '" + Me![txtmembernum] + "'"
where = where & " AND [Claim_Num] = '" + Me![txtclaim] + "'"
where = where & " AND [Tax_ID] = '" + Me![txtTaxid] + "'"
where = where & " AND [Provider_Num] = '" + Me![txtprovidernum] + "'"

Set QD = db.CreateQueryDef("Dynamic_Query", _
      "Select * from Tbl_Aus_History " & (" where " & Mid(where, 6) & ";"))

Me.Frm_Search_Subform.Form.RecordSource = "Dynamic_Query"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top