What kind of functions should be put in Form_Current event?

Voodoo_chile
Voodoo_chile used Ask the Experts™
on
What kind of functions should be put in Form_Current event? Where should I put functions such as assign recordsource for the subforms, and adjust subform size?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Architect / Application Developer
Top Expert 2007
Commented:
"Where should I put functions such as assign recordsource for the subforms, and adjust subform size?"
Normally, in the Form Load event.

The intent of the Current event is to enable/disable, make visible/invisible controls based on some condition.  The intent is *not* to set values of controls, as this makes a record (existing or new) immediately 'Dirty', ie ... edited. This is bad practice, although commonly done.

However, you could set a subform's Recordsource in the Form Current event ... based on some condition, as well as the size of the Subform Control itself ... if you have reason to do so.

mx

Commented:
>What kind of functions should be put in Form_Current event?

Anything you want to happen when the form "moves" to a new record.  For example, suppose you want to change the color of a field depending on the value it contains.

Where should I put functions such as assign recordsource for the subforms, and adjust subform size?

Usually, the recordsource for a subform is assigned in design mode.  However, if your design filters the subform based on a field in the mainform, then it might make sense to change the recordsource in the form's current event.  

I don't know when or why you might want to change the size of a subform.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
"Anything you want to happen when the form "moves" to a new record."
Of course, the Form Current event also triggers when moving through and *existing* record.

"Usually, the recordsource for a subform is assigned in design mode. "
However, when a tab control say has a subform on each tab ... a common scenario, rather than have all recordsources populating when a form opens, generally a performance hit ... you populate a subform's recordsource 'on demand' when that tab is selected.

mx

Commented:
mx,
You are correct on all counts.  My language was sloppy.  I meant "moves to a different record", not a "new" record.  
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
no.  Just trying to keep it straight :-)

mx

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial