Results 1 to 9 of 9
  1. #1
    vha7 is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2018
    Posts
    46

    How to get multi-select List Box to work to choose multiple drug names?

    Hi All,

    Access newbie here.

    I currently have a listbox that contains drug names where I manually inputted the names in 'Edit List Items' in its Row Source. On Click, I have a code where it searches for the drug name chosen in the list-box using the LIKE operator so it searches for reports/publications/results that contain the drug name in the respective column, Reference Citation, that I called it for.

    Code:
    Private Sub ListInd_Click()
    Dim myList2 As String
        myList2 = "SELECT * FROM [Publications] WHERE ([Reference Citation] LIKE '*" & Me.ListInd & "*')" _
        & "ORDER BY [Publications].[Pub Year] DESC; "
        Me.subPublications2.Form.RecordSource = myList2
        Me.subPublications2.Form.Requery
        
        applyFilt
        
    End Sub
    I have switched the Multi Select field in Form Properties to 'Simple' and/or 'Extended, but nothing seems to work. I cant seem to get the multiselect option to work where I can choose more than one option.

    Any suggestions?



    Thanks

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  3. #3
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    What is " applyFilt "?
    Are you trying to filter a subform?

    if so you need to construct a filter string and apply it.

    here's an example
    msLBXExample.zip

  4. #4
    vha7 is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2018
    Posts
    46
    Quote Originally Posted by moke123 View Post
    What is " applyFilt "?
    Are you trying to filter a subform?

    if so you need to construct a filter string and apply it.

    here's an example
    msLBXExample.zip
    This is exactly what I needed! However, my Row Source is me manually putting in values as the Row Source and not using a query and SELECT from, per se.
    Additionally, when I try to run your code, it shows an error at:

    "strList = getLBX(Me.List53, 1)"

    I have created a module for the Public Function for GetLBX but it still doesn't seem to work and displays this error:
    Click image for larger version. 

Name:	Untitled2.png 
Views:	19 
Size:	201.8 KB 
ID:	35154

  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    if you look at the arguments for getLBX the second argument is the column of the listbox you want to retrieve. Since you are using a value list I assume there is only one column. Therefore you can set the intColumn argument to 0, ie. getLBX(Me.List53, 0) or just omit the arguement as the default is column 0 ie. getLBX(Me.List53)

  6. #6
    vha7 is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2018
    Posts
    46
    Quote Originally Posted by moke123 View Post
    if you look at the arguments for getLBX the second argument is the column of the listbox you want to retrieve. Since you are using a value list I assume there is only one column. Therefore you can set the intColumn argument to 0, ie. getLBX(Me.List53, 0) or just omit the arguement as the default is column 0 ie. getLBX(Me.List53)
    Hi moke,

    I tried what you suggested, and made the intColumn argument to 0 or just omitted it fully; however, it still shows up the error: "Compile error: Expected variable or procedure, not module"

    Any suggestions?

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    just peeking at the bottom of the module navigation window it looks like you have a module called getLBX - you cannot have a module with the same name as a function. change module name to say modgetLBX

  8. #8
    vha7 is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2018
    Posts
    46
    Perfect, got it working, thanks a lot!

  9. #9
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Good eye Ajax

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

Similar Threads

  1. Replies: 10
    Last Post: 10-13-2016, 09:21 PM
  2. Replies: 15
    Last Post: 11-20-2013, 04:30 PM
  3. Replies: 1
    Last Post: 10-22-2010, 10:11 AM
  4. Replies: 1
    Last Post: 03-01-2009, 09:53 AM
  5. Replies: 1
    Last Post: 02-25-2009, 07:29 PM

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