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

SQL PROBLEM?

Status
Not open for further replies.

athos07

Programmer
Aug 1, 2002
19
AU
i have this sql code

select a_lastname, a_firstname, subject
from master
where subject = %keyword%


it dosent work, i think the problem is in the WHERE clause.
what is the correct way to right the WHERE clause to search for any word in any field of the SUBJECT field.. thanks
 
The wildcard % is okay for Access 2000 in Access 97 it is *. Since subject is a text field you need quotes surrounding the search criteria.

select a_lastname, a_firstname, subject
from master
where subject = & "'%" & keyword & "%'"

'- put the sql statement in a string and execute the string.
Dim sql as string
sql = "select a_lastname, a_firstname, subject " & _
"from master " & _
"where subject = '%" & keyword & "%'"
debug.print sql
 
ey thanks :)

hope i can retrun the favor some day

athos
 
Try using:

select ... from ... where sibject like '%keyword%'

or

sql = "select ... from ... where sibject like '%" & keyword & "%'"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top