Results 1 to 3 of 3
  1. #1
    Bcanfield83 is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    81

    Question Allow multiple items in list box to be selected; output to multi-tabbed spreadsheet

    Hello,



    I currently have a form which contains a List Box control with abouto 10 different items. Users can select an item from the list, click a button on the form, and it outputs a datasheet (opens in .xlsx file).
    This is pretty basic right now - the "On Click" property for that button uses 'Select Case' to determine which item from the List Box is selected. Then it uses DoCmd.OutputTo to open in a .xlsx file
    For each 'Case', there's a different query listed (e.g.: all 10 items in the List Box have an underlying query that outputs)
    Code:
    DoCmd.OutputTo acOutputQuery, "qryMy_Query_1", acFormatXLSX, "query1.xlsx", True
    I'd like to modify this as follows:
    1) Allow users to select multiple items from the List Box (easy enough - looks like this is a property that can be updated for the List Box control)
    2) If more than 1 item is selected, clicking the button on the form would output each query onto a separate worksheet on the ".xlsx" file. Thus if they select 3 out of the 10 items from the List Box, the 3 corresponding queries will output onto a single ".xlsx" file - with each one on a separate tab (worksheet).

    I found the below article which covers exporting to multi-tabbed spreadsheet, though I'm struggling a bit with how to coordinate the List Box selection(s) and underlying queries.

    http://justin-hampton.com/microsoft-...d-spreadsheet/

    Any help would be greatly appreciated; or, if this has been covered elsewhere, please feel free to redirect me as needed.

    Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You have to loop through the listbox selection. Review http://allenbrowne.com/ser-50.html

    Instead of the string concatenation, you would do your export code.
    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
    Bcanfield83 is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    81
    Thanks! I will take a look at the link provided and give it a shot.

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

Similar Threads

  1. Replies: 4
    Last Post: 07-27-2016, 12:07 PM
  2. Replies: 3
    Last Post: 08-13-2014, 11:07 AM
  3. Replies: 12
    Last Post: 01-08-2014, 05:15 PM
  4. Replies: 1
    Last Post: 03-05-2013, 06:53 PM
  5. Replies: 3
    Last Post: 10-23-2012, 03:32 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