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".
Public Function SetFilter()
If FilterIsOn = False Then
FilterIsOn = True
FilterIsOn = False
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)