Full Version: Filter a subform
UtterAccess Forums > Microsoft® Access > Access Forms
Wildster
Hi,
I'm trying to filter a subform so that whatever date appears within the text box tDate which is in the master form, only returns fields within the child form where the field tWeek matches the same value.
p.s. I need to still be able to input data into the DB via the subform, therefore I'm guessing this counts out using a query in the subform.
Is there a way of doing it like this?
Thanks
trapperalexander
you can still use a query for the record source of your subform. but in order to be able to edit, the query most only be based on one table. so in the query for your subform, criteria for [tweek]: =forms!YourParentForm.Form!tDate. I would also put some code in the OnExit event of [Tdate] like this:
e.YourSubform.Requery
this will update subform to the newly entered tDate as soon as you exit the tdate field.
Q: are you linking he subform to the Parent form on some other field? what are the parent/child link fields?
HTH
Wildster
Hi,
Thanks for the quick response.
A. The subform is linked to the parent form on tID.
Just a couple of questions: =
Where would I put =forms!YourParentForm.Form!tDate? In the actual query the subform is built from?
In the statement me.YourSubform.Requery, what is Requery?
Thanks for the help
trapperalexander
in your subform's query you have a field [tweek], in the criteria for this field put this expression: =forms!YourParentForm.Form!tDate
equery - When you enter a new date into tDate, you want the subform's recordsource query to re-run with the new date as the criteria.
HTH
Wildster
ahhh get you. Works a treat, thanks very much o!
trapperalexander
welcome! good luck with your project! Cheers o!
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.