- Local time
- Today, 11:16
- Joined
- Feb 28, 2001
- Messages
- 30,158
You have to remember that if there is an autonumber involved ANYWHERE, your record becomes instantly dirty based on wherever that record was first opened with a new record. Ditto if there is ANY code in the Form_Current routine that has even the slightest chance of doing something semi-permanent i.e. permanent enough to write it.
In my big-kahuna database, I have two types of forms - bound (because they are maintenance forms to single-table entities like servers, users, projects, security reports) and unbound (because they represent activities based on a JOIN query and due to the complexity of relationships, from the form that query is not updateable.)
For bound forms, your friends are the Form_BeforeUpdate event and some intelligence in the button that I use to close the form, plus your really best friend ever, the control_LostFocus event that can set a flag that says, "I'm dirty now" - and it can do something useful like make the form's navigation controls go away until you resolve the changes. Then, the Form_Close(Cancel As Integer) event becomes another friend because it can prevent you from closing a dirty form until you click some OTHER button that says, "Undo" (discard ALL changes). It takes a lot to set up, but trust me when I say that it is worth it.
As to the unbound forms, they are my worst nightmare - and my most common requirement - since you are almost guaranteed to get caught on SOMETHING or another being open at the time and therefore susceptible to record locking. Making it unbound means you have to be picky about whether you will allow an update after a delay, which is why I have "Date/Time of Last Update" and "Updated" and a couple of other flags to let the queries detect any record conflict.
In my big-kahuna database, I have two types of forms - bound (because they are maintenance forms to single-table entities like servers, users, projects, security reports) and unbound (because they represent activities based on a JOIN query and due to the complexity of relationships, from the form that query is not updateable.)
For bound forms, your friends are the Form_BeforeUpdate event and some intelligence in the button that I use to close the form, plus your really best friend ever, the control_LostFocus event that can set a flag that says, "I'm dirty now" - and it can do something useful like make the form's navigation controls go away until you resolve the changes. Then, the Form_Close(Cancel As Integer) event becomes another friend because it can prevent you from closing a dirty form until you click some OTHER button that says, "Undo" (discard ALL changes). It takes a lot to set up, but trust me when I say that it is worth it.
As to the unbound forms, they are my worst nightmare - and my most common requirement - since you are almost guaranteed to get caught on SOMETHING or another being open at the time and therefore susceptible to record locking. Making it unbound means you have to be picky about whether you will allow an update after a delay, which is why I have "Date/Time of Last Update" and "Updated" and a couple of other flags to let the queries detect any record conflict.