Use of TEXT in SQL?

aner1755

Registered User.
Local time
Today, 23:47
Joined
Jan 23, 2009
Messages
43
Hi All,
I got a problem with the value of a control when I try to implement it to a SQL query. I got two cases, the first work but not the second.
The first collect a number from a control, the second collects text from another control. I call on the controls in the same way, Me!Control1 resp. Me!Control2.
The fault is that when I use the value of Control2 (… WHERE tblProject.ProjectName = " & Me!Control2) SQL won’t recognize the value. If I change ( = " & Me!Control2) to (= ‘The string that I need’) is works perfectly fine.

I believe that it’s because the value of Me!Control2 is of data format text? I’m I right? How could I use this value in my SQL query?

Cheers!
 
You need to encapsulate text in quotes. So, a good way is to just do this:

Code:
WHERE tblProject.ProjectName = " & Chr(34) & Me!Control2 & Chr(34)
 
Bob, you saved me again! Thank you very much. :D
 

Users who are viewing this thread

Back
Top Bottom