sql query (1 Viewer)

orelv4

Registered User.
Local time
Today, 12:06
Joined
Apr 15, 2010
Messages
32
hi ,
I have a sql in my code and it doesnt work...
does enyone see any problem with my sql?
strSQL = "SELECT prog_ID FROM Program WHERE Address = ' " & iaddress & " ' "

iaddress is a variable
thanks!!!
 

boblarson

Smeghead
Local time
Today, 12:06
Joined
Jan 12, 2001
Messages
32,059
What's the rest of the code that is using it. When you say "it doesn't work" what do you mean? Does it give an error, does it do anything? How are you using strSQL? Are you opening it with a Recordset, a DLookup, What?
 

namliam

The Mailman - AWF VIP
Local time
Today, 21:06
Joined
Aug 11, 2003
Messages
11,695
Yes lots of missing info and conjecture...

But geuswork...
' " & iaddress & " ' "
Note the extra spaces there....
Try:
'" & iaddress & "'"
 

orelv4

Registered User.
Local time
Today, 12:06
Joined
Apr 15, 2010
Messages
32
you right!!!
just the spaces.
thanks!!!!... :)
 

boblarson

Smeghead
Local time
Today, 12:06
Joined
Jan 12, 2001
Messages
32,059
FYI. The closing semicolon is NOT required
Good point. That crossed my mind too as I don't ever use it in my code (it might exist in someone elses and I just leave it there when editing, but I don't include it myself).
 

Users who are viewing this thread

Top Bottom