Results 1 to 2 of 2
  1. #1
    kattatonic1 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Location
    Toronto, Canada
    Posts
    77

    applyfilter where field equals public variable on open event

    Hello,

    I have a public variable strUserName. Access is picking it up from the login screen where users choose their name.

    I'm opening a form whose data source is a table. In that table, there is a field chrAnalyst. When a user logs in (and Access picks up her strUserName), I'd like the form to open filtered for just her records. I think this should do it in my open event:
    DoCmd.ApplyFilter , wherecondition:="[chrLeadAnalyst] = '" & strUserName & "'"

    I've had trouble with the quotes in the past but I thought I had it figured out.

    I get:
    Run-time error '2046':
    "The command or action 'ApplyFilter' isn't available now."



    Why would it not be available? Is there something else I should use on an open event?

    Help appreciated!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    in a continous form,
    Code:
    me.filter = "[chrLeadAnalyst] = '" & strUserName & "'"
    me.filterOn = true

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

Similar Threads

  1. Replies: 5
    Last Post: 04-27-2015, 02:40 PM
  2. Replies: 6
    Last Post: 04-07-2015, 03:41 PM
  3. Public variable not updating for each function
    By Ruegen in forum Programming
    Replies: 3
    Last Post: 08-28-2014, 06:26 PM
  4. Replies: 1
    Last Post: 01-04-2014, 09:44 PM
  5. How to use global/public variable
    By mrbabji in forum Programming
    Replies: 7
    Last Post: 05-18-2013, 10:08 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