CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    7

    Access VBA SQL Listbox


    I'm writing some Access VBA code (DAO) for work and I want to pass the
    value the user selects in a listbox to a SQL statement (using a query).
    I tried this code:

    ....
    [querydef name]. SQL = "SELECT * FROM TBL_Contacts & _
    WHERE Country = '"lstCountry.Text"'"
    It doesn't work though--that Access "Query Parameters" dialog box pops
    up instead.
    I feel silly asking this since I'm sure there must be a simple solution,
    but I haven't been able to figure it out.. I also tried putting two sets
    of double quotes around lstCountry.Text, but that didn't work either.


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Access VBA SQL Listbox

    imho it should look like this:

    [querydef name]. SQL = "SELECT * FROM TBL_Contacts " & _
    "WHERE Country = '" & lstCountry.Text & "'"






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured