Results 1 to 6 of 6
  1. #1
    niloufar is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    24

    Lightbulb Access Form VBA filter with multiple items in a field

    On My query I have a field with multiple Names. Some are Managers and some are Auditors.



    1. On my form, I added a field with two Items , Managers and Auditors. So, when I select Managers I would like to filter my subform and query with 5 names in my record and if I select Managers, I would like to be able filter my form/query with 3 names in my record.

    below is my vba code, but it's not working,
    Code:
    Private Sub cboAuditor_AfterUpdate()
    
        strManagers = "<>'Steven' And <>'Lisa' And <>'Christopher' And <>'Ronda' "
        strAuditors = "'Steven' Or 'Lisa' Or 'Christopher' Or 'Ronda' Or 'Amber'"
    
    
            If Me.cboAuditor = "Managers" Then
                strAnalystFilter = "[Created By] = '" & strManagers & "'"
    
            ElseIf Me.cboAuditor = "Auditors" Then            
               strAnalystFilter = "[Created By] = '" & strAuditors & "'"
    
            End If
    
        End Sub

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Do yourself a major favor and do not use multi-valued fields in tables. Why M$oft did this is beyond me. It is not a concept used anywhere outside MSAccess.

    If you have a table of Auditors, then make a record for each Auditor

    tblAuditor
    AuditorID autonumber PK
    AuditorFirstName text
    AuditorLastName
    other auditor Info

    Review the use of listbox (on forms). You can select multiple items from a list box.

    If I have misunderstood your post, please provide more info and an example of input and expected output.

  3. #3
    niloufar is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    24
    Actually the Auditors List is too long and I do have auditor table.

    But, what I need is instead of having 30 name to be selected each time for Auditors in the list box, I only select Auditors on my form then the VBA select them from my table or if I have it hard coded like my code. same thing for Managers.

    I don't have position field in my query, and I don't want to use Listbox that is too much to select all names, so I want to associates those names to either as Manager on Auditors in the form.

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    I noticed your post on another forum --you should let people on a forum Know you have posted elsewhere. It's considered good etiquette and readers can check to see if you have an answer.
    That saves people who are volunteering their time and experience to help you from working on an issue that has been resolved.

    I also notice in other posts that you work with Sharepoint.

    Is this current issue related to Access desktop or sharepoint?

  5. #5
    niloufar is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    24
    yes, but my question is on another website and no I have not received any answer yet.

    LOL, you can be an good investigator

    and Yes, I do work with sharepoint, but his is not related. This suppose to be a simple form in access 2010 , but I can't put my head around this to figure out a good solution.

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    I saw in one of your databases you have a field named Position with values
    Code:
    APT BedRoom Position Location Duedate
    56AB 4 enginer; doctor; teacher; nurse SouthSide 23/07/2014
    3AS 3 engineer; doctor; nurse NorthSide 31/07/2014
    2A 2 Nurse; Teacher SouthSide
    This is not how you put data in a field in a normalized table.

    I don't know if this is a concept you are working on now in the current post, but you could tell us specifcally WHAT you are trying to accomplish, and let readers offer focused suggestions for HOW it could be done.

    As I see your current post (from guessing and 30000 ft) you should have a table of Auditors and a table of Managers.
    Putting multiple values in a field is contrary to relational database design.

    Also,see this regarding posting on multiple forums and why letting readers know is a good practice.

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

Similar Threads

  1. Replies: 8
    Last Post: 09-02-2015, 03:00 PM
  2. Replies: 1
    Last Post: 01-08-2014, 06:45 PM
  3. Replies: 8
    Last Post: 11-21-2013, 11:28 AM
  4. multiple items form
    By eraengineer in forum Forms
    Replies: 1
    Last Post: 04-17-2013, 03:33 PM
  5. Filter items shown in Combo Box in sub-form
    By mikeha_99 in forum Access
    Replies: 2
    Last Post: 06-14-2011, 12:54 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