Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2008
    Location
    St. Louis, Mo
    Posts
    1

    Variable question


    I am using Access to populate an Excel sheet, and someone around here came up with the idea of storing SQL statements in an Access database. The proble is, sometimes we need to use variables in our SQL statements. So the SQL statement 'Select * from Hdr_Reports' stores and runs fine, but if we need to store 'Select * from Hdr_Reports where Report_Name = ' & VaribleName & ', we can figure out how to make VBA read the line correctly. It translates it all to a literal string. Any idea how to get around this? Thanks in advance for your help.

  2. #2
    jya is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2007
    Location
    Chicagoland
    Posts
    109
    Did you try this?

    'Select * from Hdr_Reports where Report_Name = "' & VariableName & '"'

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Passing a value from a variable to an update query
    By MUKUDU99 in forum Programming
    Replies: 0
    Last Post: 08-24-2008, 11:14 PM
  2. Need help - Record set based on a program variable
    By ericargent in forum Programming
    Replies: 1
    Last Post: 09-19-2007, 08:57 PM
  3. pass a variable to the MsgBox function
    By 3dmgirl in forum Programming
    Replies: 2
    Last Post: 04-19-2007, 07:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums