Using a variable in SQL

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I'm trying to replace an integer number in a test WHERE string of my SQL with a variable. See below code snippet.

Works: "WHERE (((tblEvent.BitID)= 8));"

Does not work: "WHERE (((tblEvent.BitID)= " & BitNum & "));"

Any syntax suggestions appreciated.
.



Relevant Pages

  • Re: Using SQL in Sub to fill box on mouseclick
    ... In addition to Doug's point on the SQL syntax, ... This is because the first " character in your SQL string will be seen by VBA ...
    (microsoft.public.access.formscoding)
  • Re: Mailmerge, querystring and (un)logical SQL (Word 2003)
    ... Dim vsl, qs, airport_query, st_d, en_d As String ... As you can see st_d and en_d are strings formatted as dates in SQL ... the syntax of the part should be: ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Using a variable in SQL
    ... See below code snippet. ... Any syntax suggestions appreciated. ... There's no reason for that not to be working. ... How can the rest of the SQL string matter, when it works perfectly with the 8 and not with the variable? ...
    (microsoft.public.vb.database)
  • Re: Set up Parameter Query to accept more than one entry
    ... I don't know what your region field name is but I think you might have ... included two "WHERE"s in your SQL which isn't allowed. ... The expression you entered contains invalid> syntax. ... > If I try to paste the string you recommended directly into SQL View when I> save it, it gives an error message that says: ...
    (microsoft.public.access.queries)
  • SQL Syntax for a single quote in a string.
    ... I don't know how to write a syntax in SQL if there is a quote mark in a string. ...
    (borland.public.delphi.database.ado)