Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2008
    Posts
    2

    Unanswered: problem calling function

    i built a function to be connected to an autokey which on first press will run the command "filter by form",in order to choose filter criteria, and on second press will run the command "apply filter/sort" to apply the filter.

    when i call the function after opening the form independently form the database window using the autokey it works fine.
    but when i try to call it after opening the form from the switchboard form, i get an error "the command or action applyfiltersort is not available now".

    the function:

    dim FilterIsOn

    Public Function SetFilter()
    If FilterIsOn = False Then
    RunCommand acCmdFilterByForm
    FilterIsOn = True
    Else
    RunCommand acCmdApplyFilterSort
    FilterIsOn = False
    End If
    End Function

    it's worth mentioning that when i try to execute the command using the buttons on the toolbar it also works fine, but whenever i try to use it after opening the form from the switchboard, it just won't work.

    apparently it happens because the function is applied on both forms that are opened (the switchboard and my form) instead of being applied only to the focused form
    any ideas how i can adjust the function so it applies only on the form that has focus (as it happens when i click the buttons from the menu)

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Sounds like it has something to do with the way the form is being opened by the switchboard.

    I always make my own switchboard, so I dunno how much help I can be.

    Do you know how the form is being opened from the switchboard?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by barh2106
    any ideas how i can adjust the function so it applies only on the form that has focus
    Have a play with
    Code:
    Screen.ActiveForm
    George
    Home | Blog

  4. #4
    Join Date
    Jul 2008
    Posts
    2
    how can this help me? i haven't found any way to apply the "apply filter/sort" command on "Screen.ActiveForm". any chance you can help me on that?

    and another question - is it possible to know when FilterByForm is used? meaning, is there a property or a variable that indicates whether the FilterByForm window is currently opened?

Posting Permissions

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