Solved First create a record, second open a form (1 Viewer)

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:06
Joined
Feb 19, 2002
Messages
42,981
Code that is associated with a record value does NOT belong in the load event. It belongs in the Current event. the load event runs ONCE when the form is opened. The Current event runs whenever you move to a new record so it runs for EVERY record you view. If you are using form level data to control buttons, or other properties, they will never change when you go to a different record if you used the Load event to set them. So, if you never add a second record, you never notice or if the second record has the same settings as the first, you never notice.

You should also not push from the mainform to the subform since that also affects only ONE record. You should pull in the subform from the mainform You can use the subform's Current event to set the buttons.

Form and control events are not arbitrary. The original developers of Access thought long and hard about at what points you would need to add your own code. Every event has an intended use and so far you're batting 0. I've never seen a comprehensive overview of which events would be used for what purpose. I have written extensively here on the form's Beforeupdate event since it is the most important form event of all. That is the event that allows YOU to control whether or not a record gets saved and that is what Access forms are all about when you get down to it. Saving data. Preferably complete and valid data. I also write a lot about Current, and BeforeInsert. You are not alone. There is a lot of bad examples out there regarding the use of the Open and Load events.
 
Last edited:

Users who are viewing this thread

Top Bottom