Results 1 to 3 of 3
  1. #1
    apagan is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    3

    SetTempVar using ListBox Selection Value

    Can someone point me in the right direction, please...



    I am using a listbox to display options on a form. The ListBox is populated based on a query that returns 2 columns.
    On the Submit button's "On Click" event, I have an OpenReport action. The report runs a query which depends on the values that were selected from the ListBox. I want to SetTempVar based on the value of the selection made from the listbox so that the report can access the values. How can this be done?

    Thanks in advance!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    You want a pick list in a listbox. make a tPicked table to hold the items picked.
    make a form, 2 list boxes.
    1 lstAvail, holds the items to pick from
    2. lstPicked, holds the items user picked to be in the query
    User dbl-clicks from the lstAvail list, which runs an append query, and appends this option in a 'pick list' table.

    NOTE, ALWAYS refresh the listbox after the query runs. (can be done in a macro too)
    Then when all items are picked , put a button at the bottom to run the main query.
    This query joins the tPicked table to the Data table and only those items will show.

    Code:
    sub lstAvail_dblclick()
       docmd.setwarnings false
      docmd.openquery "qaAdd1Item"
      lstpicked.requery     'refresh list
    end sub
    NO CODING.
    just a few queries.
    1 append query to add the user's pick
    1 del query to erase only 1 selected item in the list
    1 del query to erase all items in the list

    Click image for larger version. 

Name:	Charge fees.jpg 
Views:	12 
Size:	24.5 KB 
ID:	37302

  3. #3
    apagan is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    3
    Thanks,
    ranman256 - looks like it will work.

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

Similar Threads

  1. Using the listbox item selection
    By George in forum Modules
    Replies: 16
    Last Post: 09-10-2017, 11:03 PM
  2. SetTempVar
    By George in forum Macros
    Replies: 14
    Last Post: 04-18-2017, 12:03 PM
  3. Replies: 10
    Last Post: 06-18-2013, 02:00 PM
  4. Replies: 1
    Last Post: 09-10-2012, 11:21 PM
  5. Deleting a ListBox Selection
    By dreamnauta in forum Programming
    Replies: 4
    Last Post: 01-27-2012, 03:14 PM

Tags for this Thread

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