Restrict records parameter

G

Guest

Hi there! Using A02 on XP. Have a form that displays one contract record and
various info on that contract. There are 2 date fields [PYEBeg] and [PYEEnd].
I have a subform linked Child/Master on mainform field [PlanNum] and subform
field [GPNum]. It shows ALL records for that contract number. What is the
best method to further restrict the records to only show 1) that contract
number and 2) records where [SearchDate] is between [PYEBeg] and [PYEEnd]?

Hope I've described it well enough. Thanks in advance for any and all help
and advice!!! I love you guys!!!
 
N

Nikos Yannacopoulos

Bonnie,

If your subform is only used as such (i.e. never opened on its own,
outside of the main form) then the easiest thing to do is to add this
filter as a condition in the query being the subform's recordsource, by
referencing the [PYEBeg] and [PYEEnd] controls on the main form,
something like:
Between Forms![MainFormName]![PYEBeg] and Forms![MainFormName]![PYEEnd]
in the criteria row under the SearchDate field in the query design grid.

There is one more thing to be done, in order to refresh the subform data
as you move from record to record. The appropriate event to fire the
refresh depends on your main form design: if [PlanNum] is just a textbox
on a bound form, then use the main form's Current event; if it is acombo
box, use the combo's Change event. In either case, the code behind the
event is:

Me.[SubformName].Requery

HTH,
Nikos
 
G

Guest

Thank you SO much for your reply. Appreciate the description and
explanation. Really glad you included the refresh note, I can use that
rather than having to close and reopen the form. Thank you for teaching me
something new today that I promise to use again and again in the future!
Thanks for participating in the newsgroups.
 

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