Results 1 to 7 of 7
  1. #1
    brett621 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    8

    Adding All to List Box

    Hello everyone,

    I have an issue with adding an "All" option to a list box. I have searched and tried things I have found but have been met with nothing but failure. Here is my issue.

    I have a table which lists office locations and utilities for those locations. As you can see with the sample information below some of the locations will have multiple utilities as different companies provide gas/electric while some have a common customer.



    Location Utility
    12 Northern Elec
    12 Northern Gas
    13 Atlantic Gas/Electric

    On a form I have a list box that will generate information related to transactions to be invoiced for each different utility. The goal is to have the list box let the user select which invoice information to generate. Currently it gives options for each of the utilities and will correctly generate the invoice information separately, having to click the "Generate" button after changing the selection. More often I would like to be able to generate all three invoices with one click, so having an "All" option would be helpful, while still having the option to invoice separately due to some special invoicing needs.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    I would use a UNION query for the RowSource of the ListBox.

  3. #3
    brett621 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    8
    I may be missing something but that will give me all the location numbers in the listbox would it not? What I was trying to do is have the list box only list each utility once and then it would use the list box to determine the correct locations (there are hundreds split between only three or four utilities).

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    What is the Row Source of the List Box now?

  5. #5
    brett621 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    8
    This is working for now to generate the correct information but will only give me each utility as a separate option with no way to select all and still have the option to generate separately:


    Select Distinct Utility from TblLocUtility


    In the tblLocUtility there are two fields Location and Utility.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    So why can't you use:
    Select "All" As Utility from TblLocUtility
    Union Select Distinct Utility from TblLocUtility

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Are you using a parameterized query as the report RecordSource? An "All" option in the list will not return any records because no record has "All" as a value. I don't use parameterized queries. I use VBA.

    DoCmd.OpenReport "reportname", , , IIf(Me.combobox = "All", "", "UtilityID=" & Me.combobox)
    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. Replies: 7
    Last Post: 01-31-2024, 09:57 AM
  2. Replies: 1
    Last Post: 06-21-2013, 03:08 AM
  3. Replies: 2
    Last Post: 04-05-2012, 08:39 PM
  4. Adding a list of tasks (at once) in a form
    By mooseisloose in forum Forms
    Replies: 8
    Last Post: 03-22-2011, 09:27 AM
  5. adding list to a listbox
    By jetrow in forum Access
    Replies: 0
    Last Post: 08-15-2006, 03:36 AM

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