Help Filtering Records On A Form

  • Thread starter Thread starter TK
  • Start date Start date
T

TK

I have a form that shows contact names and address as well the name of the
employee [employee_name] that the contact is assigned to. What I would like
to accomplish is that when a user opens the form showing all the contacts
that they be able to push a button to show ONLY those records that have been
assiged to a particular employee. (By the way there is only three
employees). Mayone one button (Button A) that shows all records for employee
A, etc.

Thanks in advance for any help that I can get.

TK
 
In the header section of your form create a new unbound
combo box control. Populate it with the values you'd like
to filter by. Use its AfterUpdate() event to filter your
form.

Private Sub MyComboBox_AfterUpdate()
Me.Filter = "[employee_name]='" & Me!MyComboBox & "'"
Me.FilterOn = True
End Sub


Good luck.
 
I would not advocate the button approach as you would have
to change the form every time the employees changed.
Instead, have a list box (or combobox) on the form that
lists the employee names. Then you could code it's
AfterUpdate event handler to set the Form's filter e.g.
DoCmd.ApplyFilter ,"employee_name = '" &
{listboxname}.Value & "'"

Hope That Helps
Gerald Stanley MCSD
 
Thank you, Thank you. This worked just fine.

TK

Elwin said:
In the header section of your form create a new unbound
combo box control. Populate it with the values you'd like
to filter by. Use its AfterUpdate() event to filter your
form.

Private Sub MyComboBox_AfterUpdate()
Me.Filter = "[employee_name]='" & Me!MyComboBox & "'"
Me.FilterOn = True
End Sub


Good luck.

-----Original Message-----
I have a form that shows contact names and address as well the name of the
employee [employee_name] that the contact is assigned to. What I would like
to accomplish is that when a user opens the form showing all the contacts
that they be able to push a button to show ONLY those records that have been
assiged to a particular employee. (By the way there is only three
employees). Mayone one button (Button A) that shows all records for employee
A, etc.

Thanks in advance for any help that I can get.

TK


.
 
Back
Top