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

    Listbox

    Experts:

    I need some assistance with (I think) a relatively easy problem. Below summarizes what I have in an Access database and what I'd like to accomplish:



    - I have a form with a listbox "ListBoxActions1"
    - Listbox "ListBoxActions1" shows eight values upon opening the form.
    - First value = "All"; remaining seven values indicate a specific category.
    - If "All" is selected, I want to enter the IF clause. If values <> "All", I want to enter the "Else" clause. Below is the pseudo code:

    Code:
    If ListBoxActions1 = "All"
       Do something
    
    Else (that is, value <> "All")
       Do something else
    
    End If
    What does the IF statement look like to ensure "All" is properly executed? Right now, when I select "All", I enter the "Else" statement (vs. the IF).

    Thank you,
    EEH

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What is the row source of the listbox? I'm guessing that "All" is not in the bound column. You may need

    If ListBoxActions1.Column(1) = "All"

    or whatever column that value is in (zero based, so 1 is the second column).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,038
    pbaldy:

    I have a category table that includes values for seven categories plus value "All". So, the row source for the list box is a simple SELECT statement.

    Does that make a difference?

    EEH

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    So, the row source for the list box is a simple SELECT statement.
    which is ?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If a single field is returned, I'd expect your code to work. Make sure there are no hidden spaces.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,038
    Attached is the sample db. For testing purposes, I have only "All" and "Accidental Discharge" in the source table for the listbox.

    So, again, if "All" is clicked I want to run "qry_Category01_All" and adding 14 records to 000_tblRawData.

    Alternatively, if "Accidental Discharge" is selected, I want to run "qry_Category02_AccidentalDischarge" and adding 2 records to 000_tblRawData.

    Please see attached database for details.

    EEH
    Attached Files Attached Files

  7. #7
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,038
    pbaldy:

    I changed "1" to "0"... it worked great!

    If ListBoxActions1.Column(0) = "All"

    Thank you for your help!!

    EEH

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you got it working!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 01-31-2015, 09:03 PM
  2. Replies: 2
    Last Post: 03-23-2014, 06:50 AM
  3. Replies: 3
    Last Post: 12-13-2012, 04:40 AM
  4. Replies: 1
    Last Post: 09-10-2012, 11:21 PM
  5. Replies: 1
    Last Post: 07-26-2012, 11:45 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