Method tiggered with new event in a subform (1 Viewer)

NT100

Registered User.
Local time
Today, 20:25
Joined
Jul 29, 2017
Messages
148
I have a main form and a subform, I wanted to know what method will be triggered when i click new in the subform.

I would be grateful for any suggestions.

NT100
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:25
Joined
Feb 28, 2001
Messages
27,001
The sub-form's BeforeInsert event is one possibility, but that typically doesn't fire until you actually type something in the new record. It is possible that NO event will fire. It depends on what you meant by your question.

Clarify please: When you say you click "New" in the sub-form... is that a command button you have created or are you clicking the triangle-asterisk in the sub-form's navigation bar. If the latter, you might have no event until you start populating the new record. However, it is also possible that the sub-form's Activate event would fire when the sub-form gains focus. If the sub-form already had focus, maybe not.
 

NT100

Registered User.
Local time
Today, 20:25
Joined
Jul 29, 2017
Messages
148
"New" means "New (blank) record" in the sub-form's navigation bar. Pls. see the attached photo.

The user clicks this "New (blank) record" to controls of this "new blank record" on the main form. Then I can validate the values entered in the controls.

The attached photo also shows the controls in the main form for the subform's "New (blank) record".

Thanks in advance.

NT100
 

Attachments

  • New (blank) record.jpg
    New (blank) record.jpg
    97.3 KB · Views: 26

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:25
Joined
Feb 19, 2002
Messages
42,981
If the record you are viewing (main form or subform) is dirty - meaning that there is an unsaved modification - then the form's BeforeUpdate and form's AfterUpdate events will fire for that record and then the Current event will fire for the new record. Other events might also fire. For example, a contro's BeforeUpdate and AfterUpdate events as well as lostfocue might fire. Events fire in a proscribed order but ONLY if Access determines that they need to fire. For example, if you change control1 and control2 and then click the new record in the subform, the control level events for control2 have not yet fired so they need to fire before the form level events fire. However if you changed control1, and then moved to control2 but didn't change it, there is no need to fire the control's BeforeUpdate and AfterUpdate events because you didn't modify the control. However, you did enter it so the lostFocus event would need to fire followed by the form level events.

What are you trying to do?
 

Users who are viewing this thread

Top Bottom