Results 1 to 2 of 2
  1. #1
    dscottf is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2015
    Posts
    6

    FilterByForm Macro then ApplyFilter


    I have a form containing many records that I want to filter. I created a macro to use the "RunMenuCommand" with FilterByForm as the argument. It works great, but I have to right click on the form to gain access to the Apply filter command. I tried creating another macro with command button to use the "RunMenuCommand" with the Apply Filter argument. The problem is this button is grayed out when the Filter By Form is active and I'm unable to access it. Is there a way to create this?

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Quote Originally Posted by dscottf View Post
    I have a form containing many records that I want to filter. I created a macro to use the "RunMenuCommand" with FilterByForm as the argument. It works great, but I have to right click on the form to gain access to the Apply filter command. I tried creating another macro with command button to use the "RunMenuCommand" with the Apply Filter argument. The problem is this button is grayed out when the Filter By Form is active and I'm unable to access it. Is there a way to create this?
    I have a simple table with the following fields:

    tblEmployee
    employee_code(Integer)
    employee_name(Text)
    employee_DOB(Date/Time)

    I have build a form and I have a text box in which I would like to type the employee code to filter my form accordingly. Command5 Button filters the form and Command6 Button Clears the filter.

    Private Sub Command5_Click()
    Me.Filter = "[employee_code]=" & Me.Text3
    Me.FilterOn = True


    End Sub


    Private Sub Command6_Click()
    Me.FilterOn = False
    End Sub

    You can use this to filter your form using the employee name which will require a slight adjustment in the code:
    Private Sub Command5_Click()
    Me.Filter = "[employee_name]='" & Me.Text3 & "'"
    Me.FilterOn = True

    and for date

    Private Sub Command5_Click()
    Me.Filter = "[employee_DOB]=#" & Me.Text3 & "#"
    Me.FilterOn = True

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

Similar Threads

  1. Replies: 15
    Last Post: 10-02-2015, 12:07 PM
  2. Replies: 2
    Last Post: 06-17-2015, 12:20 PM
  3. ApplyFilter in ACCDR
    By Cedarguy in forum Access
    Replies: 5
    Last Post: 05-11-2015, 05:49 AM
  4. Help with ApplyFilter
    By kabichan in forum Programming
    Replies: 1
    Last Post: 01-15-2010, 09:21 PM
  5. Using ApplyFilter in Form...help please
    By playfuljade in forum Forms
    Replies: 8
    Last Post: 12-19-2005, 09:35 AM

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