简体   繁体   中英

MS Access 2007 subform reload on formheader = visible?

I'm getting strange behavior in Access 2007 on a form designed in Access 2003.

I have an unbound main form with a data-bound subform. Within the Form_load of the main form, I set the subform sourceobject, which loads the subform recordset, etc. After the subform loads, but still within the Form_load of the main form, I set Me.FormHeader.Visible = True . After this line runs, for some reason the subform seems to close and reopen -- its Form_Unload fires, and it runs through its load process again.

Any idea why this would be happening? It's annoying, because its recordset is based on a parameter query, and the parameters get zapped when it reloads so it ends up prompting users for parameters.

Sometimes you have to live with (and work around) the behavior of MS Access, no matter how strange or annoying it is.

In this case I would probably advise that you move away from a parameter query and instead prompt the user for their input using VBA, store their input in a form level variable, and use that input to set the recordsource during the subform's Form_Load event. This way the user will only be prompted one time and never need to know that the form actually loaded twice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM