help on filtering subforms!

  • Thread starter Thread starter Morgan
  • Start date Start date
M

Morgan

I have a form called "Expenses" and a subform
called "expenses subform" witch show expenses by employee.
What I would like to do is use a combo box on the
form "Expenses" to filter the subforms records. combo box
items "Current" ( to show current month) "last month" (to
show last month) "Year to date" ( show all). I want to
show records depending on what is selected in the combo
box. If it is possible to do so, can some one help.

Thanks Morgan.
 
what i would do if i were you, is this

subforms are based on SQL statements

so put a statement like this in the OnClick or better is
OnChanged event of your combo box:

Select Case ComboBox.ListIndex
Case 0 'Current
'Change the SQL to filter to Current Month

Case 1 'Last Month
'Change the SQL to filter to Last Month

Case 2 'Year to Date
'Change the SQL to filter to this year

etc...

End Select

'here update/requery the subform

actually it might be better to put that code into
an 'UpdateMySubForm' type subroutine, and then call it
from MyComboBox_OnChanged/OnClick

cuz you'd probably also want to call it on Form_Load as
well

hope this helps
 
Back
Top