subform

C

ChristieB

I have a form and a subform. The subform is based off a table and the form
performs calculations from different fields and tables. One field in my
subform is : Date Worked. What's the best way to show only records where the
date worked falls between two other dates? I can't query a subform, so can I
filter the subform from the form, and how. Pretty new to this, so any
suggestions with details would help me greatly. Thanks
 
A

Allen Browne

Typcially a main form is bound to a table, and the subform shows just the
related records from another table. I'm not sure if you are asking how to:

a) filter the subform, so that it only shows the records where the [Date
Worked] is in a specific range.
OR
b) filter the main form so it only shows the records that have a record
where the [Date Worked] field is in a specific range,

If (a), you can put a couple of unbound text boxes in the Form Header
section of the subform, where the user can enter the 2 dates. Then use logic
like Method 2 in this article to create the filter string, and use it as the
form's filter:
http://allenbrowne.com/casu-08.html
That article ends up using the filter for a report. Instead of the
OpenReport, line, you will end up with:
Me.Filter = strWhere
Me.FilterOn = True
Please note that if you filter the main form and the subform both, Access
gets confused:
http://allenbrowne.com/bug-02.html

If you wanted (b), see:
Filter a Form on a Field in a Subform
at:
http://allenbrowne.com/ser-28.html
 

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