Filtering subform field

  • Thread starter Thread starter shaggles
  • Start date Start date
S

shaggles

How can I apply a filter to a subform? I have a main form
with general office info and a subform with all employees
listed for that office. The people who will be using this
db want show only current employees on the subform as the
default but want to be able to expand the view to show
employees terminated within date parameters they will
enter in an input box. THis is confusing me in a couple
of ways. First how to refer to the subform or it's
underlying query. Second what they really want is an
already filtered recordset with the ability to 'relax' the
filter parameters. Any ideas?
 
Try this.

Dim frm as Form
Dim dteStart as Date
Dim dteEnd as Date
Set frm = Me!SubFormControlname.Form
If frm.FilterOn Then
frm.Filter = ""
frm.FilterOn = False
Else
dteStart = InputBox ("Enter Start Date")
dteEnd = InputBox ("Enter End Date")
frm.Filter = "[TermDt] Between #" & dteStart & "# " _
& "And #" & dteEnd & "#"
frm.FilterOn = True
End If
 
Back
Top