Is there a way to stop subforms from loading until a specific main form control has a value? I need a certain value to be set so that I can filter the query results for several different subforms.
ETA: I've added much more information below for anyone who finds it helpful to see what it is I'm try to accomplish and why. Feel free to disregard if you want as the above question is what it boils down to (I think?).
I'm probably making this much more complicated than it needs to be, but here goes...
I'm designing a time sheet database. Because of the layout of the form, which the user wants to look like a traditional time sheet, I decided the best way to achieve that and still keep a normalized table was to use a form/subform(s) setup. Tables involved are tblEmployees and tblTimeSheets. Main form (frmTimeMain) has employee ID, an unbound date field for the week ending date (txtWkEnding) which the user fills out via the DatePicker, and 7 other unbound date fields (txtSuDate, txtMDate, etc.) that get their value once the user picks the week ending date. I then put code in the OnChange event of txtWkEnding so that once the user picks the date and the 7 unbound controls get their values, each of the subforms (sbfChildSu, sbfChildM, etc.) date fields (which are not visible to the user) also get their values from the corresponding unbound field on the main form. So if the user chooses 10/21/2017 as the Week Ending Date, the value of parent form control txtSuDate will be 10/15/17 and the value of sbfChildSu's txtDate control will also be 10/15/17.
This works great if I want to set everything to only allow new records. But it occurred to me as I was testing things out that someone might need to actually edit those time sheets on occasion (duh). Problem though...when I reopen the form, every record shows up in every subform. So then I thought - Hey! I'll just change the RecordSource of the subforms to queries and then I can set criteria to filter the data so that only records with dates that match the corresponding main form date fields will be in each subform. So the underlying query for sbfChildSu's criteria will look for and filter records by what's in the main form's txtSuDate field, etc. That won't work though, because the subforms load before the user sets the dates.
ETA: I've added much more information below for anyone who finds it helpful to see what it is I'm try to accomplish and why. Feel free to disregard if you want as the above question is what it boils down to (I think?).
I'm probably making this much more complicated than it needs to be, but here goes...
I'm designing a time sheet database. Because of the layout of the form, which the user wants to look like a traditional time sheet, I decided the best way to achieve that and still keep a normalized table was to use a form/subform(s) setup. Tables involved are tblEmployees and tblTimeSheets. Main form (frmTimeMain) has employee ID, an unbound date field for the week ending date (txtWkEnding) which the user fills out via the DatePicker, and 7 other unbound date fields (txtSuDate, txtMDate, etc.) that get their value once the user picks the week ending date. I then put code in the OnChange event of txtWkEnding so that once the user picks the date and the 7 unbound controls get their values, each of the subforms (sbfChildSu, sbfChildM, etc.) date fields (which are not visible to the user) also get their values from the corresponding unbound field on the main form. So if the user chooses 10/21/2017 as the Week Ending Date, the value of parent form control txtSuDate will be 10/15/17 and the value of sbfChildSu's txtDate control will also be 10/15/17.
This works great if I want to set everything to only allow new records. But it occurred to me as I was testing things out that someone might need to actually edit those time sheets on occasion (duh). Problem though...when I reopen the form, every record shows up in every subform. So then I thought - Hey! I'll just change the RecordSource of the subforms to queries and then I can set criteria to filter the data so that only records with dates that match the corresponding main form date fields will be in each subform. So the underlying query for sbfChildSu's criteria will look for and filter records by what's in the main form's txtSuDate field, etc. That won't work though, because the subforms load before the user sets the dates.
Last edited: