Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2011
    Posts
    31

    Unanswered: Selecting more than one or all options from a droplist

    I have a list box who's source is a range of values of patient sizes from a table: Adult (Medium), Adult (Large), Adult (Small), Paediatric (Large) etc.

    I would like to add an option for "ALL" or a means of using 'Ctrl' to allow the user to select more than one. Currently the values from the table are linked to criteria within queries from a form. When the user makes a selection on the form, that selection specifies the criteria within the query which runs once the user clicks on a button.

    How would i go about implementing the option for all or allow the user to select more than one option in the droplist?

  2. #2
    Join Date
    Oct 2003
    Location
    London
    Posts
    341
    In the properties of the listbox, under the 'Other Tab', there is the option of 'Multi Select'.

    By default it's none, but you have the choice of Simple or Extended.

    Simple means click once to select
    Extended means hold the CTRL or SHIFT to select

  3. #3
    Join Date
    Oct 2003
    Location
    London
    Posts
    341
    To "Select All" you would probably need to add a button with the following behind;

    Code:
    Private Sub SelectAll_Click()
    
    Dim i
    
        For i = 0 To Me.List01.ListCount - 1
            Me.List01.Selected(i) = True 'or False if you wanted a "UnSelect All" option
        Next i
    
    End Sub

  4. #4
    Join Date
    Jun 2011
    Posts
    31
    Quote Originally Posted by christyxo View Post
    In the properties of the listbox, under the 'Other Tab', there is the option of 'Multi Select'.

    By default it's none, but you have the choice of Simple or Extended.

    Simple means click once to select
    Extended means hold the CTRL or SHIFT to select
    My mistake, i was using a combo box so it doesn't have the option of "Multi Select". I think i may just have to replace the combo boxes i use for listboxes instead.

  5. #5
    Join Date
    Jun 2011
    Posts
    31
    Listboxes do work wonderfully to display the data and make multiple selections but i realize they now screw up how my query ran before....

    Initially i had set the criteria for a query based on refering to the selection from the form with "[forms]![GenRADForm]![cboSize]", now with the specification of "[forms]![GenRADForm]![lstSize]" i get no results, any idea as to why and how i can overcome this?

    I looked at these:
    http://www.dbforums.com/microsoft-ac...ist-boxes.html
    http://www.databasedev.co.uk/query_using_listbox.html

    But it might as well have been written in brail...my visual basic in access is non-existent.

    The rowsource of values come from a table known as 'RESULTS' using "SELECT DISTINCT [RESULTS.Patient Size] FROM RESULTS ORDER BY [RESULTS.Patient Size]; "
    I want to use the selected sizes from 'lstSize' to specify the parameter/criteria of patient size to perform another query called 'PercentGenResults'. Figured there would be some fancy code to do this....but i don't even know how to execute any code even if i did write it. HELP

    Second link provided what looks like a better application, but i tried modifying the program for a 'btnOK' buttom and it did not even run my 'PercentGenResults' query....HELP ME :'(
    Last edited by clownyj; 07-19-11 at 16:08.

  6. #6
    Join Date
    Oct 2003
    Location
    London
    Posts
    341
    What is the SQL of your second query?

    It just sounds like you need to amend the SQL along the lines of

    SELECT Table1.Field1,
    FROM Table1
    WHERE (((Table1.Field1)=[Forms]![Form1]![List01]);

    I'm not sure how this would work if you were selecting multiple lines in a list box but I'm sure there would be around it. this would at least be a starting point.

  7. #7
    Join Date
    Jun 2011
    Posts
    31
    Quote Originally Posted by christyxo View Post
    What is the SQL of your second query?

    It just sounds like you need to amend the SQL along the lines of

    SELECT Table1.Field1,
    FROM Table1
    WHERE (((Table1.Field1)=[Forms]![Form1]![List01]);

    I'm not sure how this would work if you were selecting multiple lines in a list box but I'm sure there would be around it. this would at least be a starting point.
    Same effect as specifying the criteria as '[Forms]![GenRADForm]![lstSize]', has something to do with how it notes the selections made from the list...having a warm time trying to make sense of it. If push comes to shove i'm going to have to go back to a combo box which would only allow one selection.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •