Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Arkansas, USA
    Posts
    163
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Filter by Form (Access 2K)

    I need a little help regarding filter by form. I placed a command button on a form which runs a macro which allows the user to filter by form. However when the filter by form command is executed, all of the other command buttons are grayed out and I cannot have a button to execute the filter by form once selections have been made. I would like to allow the user to press enter to execute the filter, but do not know how exactly to do this. I have been leaving the toolbar containing the apply filter button available, but would like to hide this toolbar and make this more user friendly for those who are not familiar with access.

    Thanks in advance for any help.

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Filter by Form (Access 2K)

    Filter by Form opens in its own window, which is why the command buttons are disabled. Pressing the Enter key in the Filter by Form window will either move cursor to next field, or do nothing, depending on what Keyboard options are set for "Move after Enter." I think you're stuck with the toolbar.

    You have the option of creating a custom toolbar to replace built-in Filter/Sort toolbar and setting properties such as "Image and Text", ScreenTips, etc in effort to make toolbar more "user-friendly" than built-in one. Attached illustration shows example of custom toolbar named "CustomFilter" with custom ScreenTip displayed. To display your custom toolbar in place of built-in one use code like this:

    For command button that opens Filter by Form window:
    <pre>DoCmd.RunCommand acCmdFilterByForm
    DoCmd.ShowToolbar "CustomFilter", acToolbarYes
    DoCmd.ShowToolbar "Filter/Sort", acToolbarNo</pre>

    For form's OnApplyFilter event:
    <pre>Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)

    Select Case ApplyType
    Case 1 'Apply filter
    DoCmd.ShowToolbar "CustomFilter", acToolbarYes
    DoCmd.ShowToolbar "Filter/Sort", acToolbarNo
    Case 0, 2 '0 = Remove filter, 2 = close Filter by Form window
    DoCmd.ShowToolbar "CustomFilter", acToolbarNo
    End Select

    End Sub</pre>

    For form's OnClose event you'd also want:
    <pre>DoCmd.ShowToolbar "CustomFilter", acToolbarNo</pre>

    in event form closed with filter still applied.

    HTH
    Attached Images Attached Images

  3. #3
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Arkansas, USA
    Posts
    163
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filter by Form (Access 2K)

    Thank you for the help.

Posting Permissions

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