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

Whare is my syntax error... 1

Status
Not open for further replies.

rbasram

Programmer
Sep 27, 2001
53
CA
How to check for syntax errors in the query...I am unable to execute this query it gives me syntax error can someone help. txtTracking is a text box..


str1 = "SELECT * FROM CancelTracking WHERE [Tracking#]= & txtTracking ;"


Thank-you...
 
Hi!

str1 = "SELECT * FROM CancelTracking WHERE [Tracking#]= " & txtTracking & ";"

This assumes that Tracking# is numeric. BTW, I have had a lot of trouble with field names that include # because Access uses the # sign to set off dates.

hth
Jeff Bridgham
bridgham@purdue.edu
 
str1 = "SELECT * FROM CancelTracking WHERE [Tracking#]= & txtTracking ;"

A couple of things wrong. Anything within the quotes will be treated as text, so you need to resolve the variable before putting it in the string (str1). Also, a text variable must be surrounded by quotes. chr$(34) equals "

str1 = "SELECT * FROM CancelTracking WHERE [Tracking#]= "
str1 = str1 & chr$(34) & txtTracking & chr$(34)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top