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

SQL keyword LIKE??

Status
Not open for further replies.

goatsaregreat

Programmer
Mar 21, 2001
82
GB
I am doing a query of a fairly large DB. Each record in the DB has a unique "job #". Every year has its own prefix. what I am trying to do is to query out all the records for one year. I am picking the year with a combo box. Here is the query I am using. I cannot get the "Like" keyword to concatenate the "DB"(prefix) and the combobox which is the year. TIA for your help, and if it is not possible, please tell me, and I'll do it another way. Thanx.

db.Execute "select * into " & Combo1.Text & " " & _
"from maindata " & _
"where [Job #] like 'DB' & Combo1.Text & " " & _
"order by [Job #]"
 
don't know SQL from s..t but could you have misplaced/forgotten a double-quote someplace?

try
Code:
db.Execute "select * into " & Combo1.Text & " " & _
            "from maindata " & _
            "where [Job #] like 'DB'" & Combo1.Text & " " & _
            "order by [Job #]"

or
Code:
db.Execute "select * into " & Combo1.Text & " " & _
            "from maindata " & _
            "where [Job #] like DB" & Combo1.Text & " " & _
            "order by [Job #]"
 
Yeah - got it...

The second reference to the combo box is actually inside a string literal... Problem with your quotes...

Try
Code:
db.Execute "select * into " & Combo1.Text & " " & _
            "from maindata " & _
            "where [Job #] like 'DB'" & Combo1.Text & " " & _
            "order by [Job #]"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top