form filtering

  • Thread starter Thread starter Troy
  • Start date Start date
T

Troy

hello, I have a table with the following fields.

Dept
Employees

I would like to be able to view only the employees in the current dept from
a drop down menu, or navigation buttons. How can I accomplish this?

TIA
 
Troy

You posted in a "forms" newsgroup, so you'll get a "forms" response.

One approach, if you only wish to view them, would be to create an unbound
form. Add a combo box that uses only the Departments (unique departments)
as a source.

Add a listbox, with a source set to use the combo box's selection as a
criterion (i.e., something along the lines of

WHERE [Dept] = Forms!YourForm!cboYourComboBox

In the combo box's AfterUpdate event, requery the listbox, with something
like

Me!lstYourListBox.Requery
 
Troy said:
hello, I have a table with the following fields.

Dept
Employees

I would like to be able to view only the employees in the current dept from
a drop down menu, or navigation buttons. How can I accomplish this?

TIA

Using a ComboBox or ListBox Wizzard you can check for Find
function.
In this way you have all recordset on form but the pointer is on
your combo chois.

If you like more have only the selected one, the fast solution can be
apply the filter:

On After_Update Combo/List control event write:

Me.FilterOn=False
' If Numeric Field
Me.Filter=[FieldName=" & Me.ComboName
' If text Field
'Me.Filter=[FieldName=" & chr(34) & Me.ComboName & chr(34)
Me.FilterOn=true


Hope this help
 
Alessandro I have tried the Me.Filter code using a combo box that you've
previously written but I can't seem to get it to work. Any idea why?

ALESSANDRO Baraldi said:
Troy said:
hello, I have a table with the following fields.

Dept
Employees

I would like to be able to view only the employees in the current dept from
a drop down menu, or navigation buttons. How can I accomplish this?

TIA

Using a ComboBox or ListBox Wizzard you can check for Find
function.
In this way you have all recordset on form but the pointer is on
your combo chois.

If you like more have only the selected one, the fast solution can be
apply the filter:

On After_Update Combo/List control event write:

Me.FilterOn=False
' If Numeric Field
Me.Filter=[FieldName=" & Me.ComboName
' If text Field
'Me.Filter=[FieldName=" & chr(34) & Me.ComboName & chr(34)
Me.FilterOn=true


Hope this help
 
Back
Top