Full Version: When Do You Set The Recordsource Of A Subform?
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
ccIces
Do you put the recordsource code on the form's load event or open event?
I understand the order of events but not clear on the load events purpose. From what I have read, it fires after the data loads. If this is correct, then my recordsource code should go on open event no?
theDBguy
Hi,

Why not just directly use the Record Source property? If you're trying to dynamically change the record source, then yes, I think the Open event is appropriate.

Just my 2 cents... 2cents.gif
ccIces
for this instnace, the rs will change on a preset time so it is a function that recalculates the recordset based on the time.
But, when the form/subform first loads, I currently have the recordsource unbound. So although it onlyhappens in testing, the form comes up with #name in the controls as they are bound to the names of what the record set contains. So, I wanted to add the call to the sub routine as the form opens to populate set the recordsource but I did not know if it would be better on open or load.
After playing with it for a few, Isee that it should go on open - if it is on load, then it first appears with #name in the controls then flashes to the correct recordsource. Which now that I think about it, makes the event order make sense!
Thanks!
theDBguy
Hi,

Couldn't you just set the RecordSource property in Design View to avoid the #Name error? You should still be able to change it in code when you need to recalculate the data.

Just my 2 cents... 2cents.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.