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

How can I search across several fields with the same string ??

Status
Not open for further replies.

Computethis

IS-IT--Management
Feb 5, 2001
28
US
I need to search across several fields for the same information?

Any help ??

Thanks,
David
 
You can do this a couple of ways, either with a parameter query or query by form. Either way you add the same criteria expression in all the fields you wish to search on. Since it's unlikely that the same information will be in more than one field for any given record you'll want to insure you put the criteria expression on different lines.
 
Hi Computethis,

Try out this
****************************************
Private Sub cmdKYGO_Click()
Dim strKWQUERY As String
Dim strSRCH As String
strSRCH = txtSEARCH.Value
Dim dbHIV As Database
Dim qdfKWSRCH As QueryDef
Set dbHIV = CurrentDb
strKWQUERY = "select * from 1a where [1a.8] like '*" & strSRCH & "*'" _
& " or [1a.11] like '*" & strSRCH & "*'" _
& " or [1a.13] like '*" & strSRCH & "*'" _
& " or [1a.44] like '*" & strSRCH & "*'" _
& " or [1a.46] like '*" & strSRCH & "*'" _
& " order by [1a.1]"

Set qdfKWSRCH = dbHIV.CreateQueryDef("KW_SRCH", strKWQUERY)
dbHIV.QueryDefs.Refresh
DoCmd.Openquery "KW_SRCH"
End Sub

enjoy

Shyam

Shyam
cwizshyam@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top