Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    Feb 2002
    Location
    Blacktown, Sydney, New South Wales, Australia
    Posts
    175
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Filter by Form (AC2K)

    I have created a search screen, in which I have placed three command buttons, using the Tool Box Wizard. These buttons are 1) Filter by Form; 2) Apply Filter, and 3) Show all records. I have adjusted the code for 2 & 3 to select appropriate menu item via DoCmd.DoMenuItem.

    The problem is that the 'Filter By Form' button works fine, but the other two buttons are 'dimmed' (ie not available). The Apply filter button on the Menu Bar however, is OK. I have searched this forum and the MS Knowledgebase, looking for a solution, but either I am using the wrong search criteria or its not there.

    Could anyone point me to an article on correctly setting up these commands buttons, as I want to disable the menu bar when the application is complete.


    TIA

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filter by Form (AC2K)

    Did you happen to set the Enabled property for those command buttons to No?

  3. #3
    2 Star Lounger
    Join Date
    Feb 2002
    Location
    Blacktown, Sydney, New South Wales, Australia
    Posts
    175
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Filter by Form (AC2K)

    Morning Hans,

    I have just checked. All are 'Enabled' properties are set to Yes

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filter by Form (AC2K)

    Sorry, I don't understand how this can happen. As far as I know, command buttons don't have built-in intelligence that enables/disables them.

    Could you post the On Click code for one of the disabled buttons?

  5. #5
    2 Star Lounger
    Join Date
    Feb 2002
    Location
    Blacktown, Sydney, New South Wales, Australia
    Posts
    175
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Filter by Form (AC2K)

    Here is code

    Private Sub Command20_Click()
    On Error GoTo Err_Command20_Click
    ' Set form to 'Filter by Form'

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 0, 0, acMenuVer70

    Exit_Command20_Click:
    Exit Sub

    Err_Command20_Click:
    MsgBox Err.Description
    Resume Exit_Command20_Click

    End Sub
    Private Sub Command21_Click()
    On Error GoTo Err_Command21_Click
    ' Apply Filter

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70

    Exit_Command21_Click:
    Exit Sub

    Err_Command21_Click:
    MsgBox Err.Description
    Resume Exit_Command21_Click

    End Sub
    Private Sub Command22_Click()
    On Error GoTo Err_Command22_Click
    ' Show All Records

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 3, , acMenuVer70

    Exit_Command22_Click:
    Exit Sub

    Err_Command22_Click:
    MsgBox Err.Description
    Resume Exit_Command22_Click

    End Sub

    Complete zipped database (currently WIP with only test data), is only 190 kb. I could e-mail it to you if this would help

    Thanks again

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filter by Form (AC2K)

    Thanks; this is the standard wizard-generated code; it contains nothing that enables/disables the command buttons, so I still don't understand.

    If you remove all database objects (tables, queries, forms etc.) not needed to demonstrate the problem, you should be able to get the zipped version below 100 KB (do this on a copy, of course.) See <post#=371550>post 371550</post#> for more detailed instructions.

  7. #7
    2 Star Lounger
    Join Date
    Feb 2002
    Location
    Blacktown, Sydney, New South Wales, Australia
    Posts
    175
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Filter by Form (AC2K)

    Cut down version of d/base attached.
    When Search Form is opened, all three buttons are enabled. By clicking the Top Button (Edit Filter), the other buttons appear dimmed. The Menu Bar button equivalents are enabled.
    Attached Files Attached Files

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filter by Form (AC2K)

    This is different from what you first described. You originally wrote
    <hr>The problem is that the 'Filter By Form' button works fine, but the other two buttons are 'dimmed' (ie not available).<hr>
    Now you write
    <hr>When Search Form is opened, all three buttons are enabled.<hr>
    When you activate the form filter, ALL command buttons on the form are disabled. This is by design, since command buttons don't play a role in setting a filter.

    This means that your setup won't work. You will have to create a custom toolbar with copies of the built-in toolbar buttons for filtering (and other buttons you want to make available.) Set the Toolbar property of the form to the name of the custom toolbar.

  9. #9
    2 Star Lounger
    Join Date
    Feb 2002
    Location
    Blacktown, Sydney, New South Wales, Australia
    Posts
    175
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Filter by Form (AC2K)

    Thank you Hans, sorry for confusion, musta been my Aussie accent.

    Will investigate Custom Tool Bar option

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filter by Form (AC2K)

    An alternative would be to create your own form to specify the filter - see MSKB article ACC2000: Filter By Form Example for Run-Time Applications Available in the Download Center for an idea of how to do this.

Posting Permissions

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