Results 1 to 4 of 4
  1. #1
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,038

    Listbox (single) value selection into query criteria

    Experts:



    Can someone point me to a downloadable database example which allows me to select a *single* listbox item (on a form) and then passes/stores the selected value -- via VBA -- into an existing query criteria (i.e., into the where clause)?

    Preferably, I don't want the query criteria to reference the form's listbox... instead, after the form's event, I'd like to actually see the selected listbox value in the query.

    Thank you,
    EEH

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    List box must have MultiSelect set to None.

    Queries don't like to reference listboxes. Have a textbox with expression referencing the listbox. It can be not visible.

    Then can reference textbox in query.

    You won't see the listbox value in query WHERE clause. The only way to do that would be VBA using QueryDefs to modifying query design.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,038
    Please see related but different thread.

    https://www.accessforums.net/showthread.php?t=77996

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    You can reference listbox in VBA just as you would a textbox or combobox. So exactly what is issue?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Using a Listbox to build criteria for a query
    By RayMilhon in forum Queries
    Replies: 11
    Last Post: 03-06-2016, 10:44 AM
  2. Query criteria from Combo box selection
    By caniread in forum Queries
    Replies: 3
    Last Post: 01-09-2016, 09:09 PM
  3. Replies: 7
    Last Post: 07-08-2015, 09:54 AM
  4. Replies: 10
    Last Post: 06-18-2013, 02:00 PM
  5. Replies: 1
    Last Post: 09-10-2012, 11:21 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