Results 1 to 4 of 4
  1. #1
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94

    Me.Filter with variable woes

    I am having a difficult time setting a filter criteria based on a text field entered prior to the filter being set and turned on.



    Basically, the value of the variable is not being passed to the filter properly. In each instance, the MsgBox command validates that the proper value is set in the variable.

    Here's my code with several attempted commands and their results:

    Code:
        MsgBox "NUID: " & Me.TextLoginNUID, 0
                
    '    Me.Filter = "[NUID] = " & "Me.TextLoginNUID"    ' This one seems to not error out - but prompts for Me.TextLoginNUID
            
    '    Me.Filter = "[NUID] = 'P482017'"               ' This works properly - but without a variable
    
    '    Me.Filter = "[NUID] = " & Me.TextLoginNUID      ' This one prompts for Me.TextLoginNUID but places the value of Me.TextLoginNUID in the title of the prompt
        
    '    Me.Filter = "[NUID] = Me.TextLoginNUID"        'This prompts for Me.TextLoginNUID"
        
        Me.FilterOn = True
        Me.Requery

  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
    Since your value is text, try


    Me.Filter = "[NUID] = '" & Me.TextLoginNUID & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94
    That did the trick. Thank you

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem. That adds the apostrophes you had in your working example.
    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: 5
    Last Post: 05-29-2012, 08:50 PM
  2. Combo Box Woes
    By tbassngal in forum Forms
    Replies: 2
    Last Post: 09-01-2011, 08:54 AM
  3. error message woes
    By ggs in forum Forms
    Replies: 4
    Last Post: 05-29-2011, 04:03 AM
  4. Variable Filter
    By breana in forum Queries
    Replies: 5
    Last Post: 03-11-2011, 11:08 AM
  5. Combo box woes...
    By jonbonazza in forum Forms
    Replies: 3
    Last Post: 06-21-2010, 11:34 AM

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