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

refering to a variable in SQL string

Status
Not open for further replies.

jamessl

Technical User
Jul 20, 2002
20
0
0
DK
Hi this should be simple -

I just need to refer to a variable in an SQL string in my VB code.

The string is -

rstUpdate.Open "SELECT * FROM [Customer Orders] WHERE [Cancel Booking] = False AND [Date Ordered] > #08-20-02# AND [Tour Date] > #" & Format(Date, "dd-mm-yy") & "# AND [Invoiced] = False AND [Payment Type] = 'Invoice' AND [Customer Name] = '" & CustomerName & "'", conn, 1, adLockOptimistic

The variable argument I'm having trouble with is in the WHERE clause where it refers to CustomerName. CustomerName is a variant type variable which contains text data. What is the correct way to refer to a control or variable in an SQl string in VB. Dates are easy, just put some #'s around the outside eg #" & startDate & "# should works fine, but what about text???

help aprreciated!

cheeers

 
Please don't answer this - the SQL syntax is fine. Just had a cup of coffee and woke up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top