Results 1 to 2 of 2
  1. #1
    blacksaibot is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Posts
    34

    Query criteria retrieved from a Form's listbox

    Right now on my form I have a comobox options within.
    The query takes the selection from the form combobox like so:

    [forms]![formname]![comboboxname]

    It successfuly retrieves what the user selects, but how can I do the same thing but with a listbox that has a multiselect??

    Would I have to right a loop that goes through each selected item and make a string with concatenations that will be part of my query?

    Not sure about VBA syntax either. Is it the same as VB.NET?

  2. #2
    Guus2005's Avatar
    Guus2005 is offline Carbon based thingy
    Windows 7 Access 2003
    Join Date
    Jan 2010
    Location
    the netherlands
    Posts
    42
    First, VBA and VB.Net are totally different. You can't compare them.

    For the listbox with multiselect you need to create a string of items separated by comma's. The string might look like this: "1,2,3,4,5,6"
    Your query might then look like this:

    Code:
    select * from tablename where id in (1,2,3,4,5,6)
    HTH

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

Similar Threads

  1. Query Criteria
    By Texaine in forum Queries
    Replies: 1
    Last Post: 01-24-2018, 02:36 PM
  2. Query criteria retrieved from a Form combobox?
    By blacksaibot in forum Queries
    Replies: 1
    Last Post: 01-27-2010, 10:18 AM
  3. Replies: 1
    Last Post: 12-10-2009, 09:58 PM
  4. Replies: 3
    Last Post: 07-30-2009, 07:12 AM
  5. using form's control as criteria in a query
    By brandonb in forum Access
    Replies: 0
    Last Post: 06-09-2009, 02:52 PM

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