Filtering subform field

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?
 
E

Elwin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top