Diff between On Open and On Load

  • Thread starter Thread starter Joyce
  • Start date Start date
J

Joyce

Does it make a difference where I place a command in
reguards to on open and on load?

I also want the field for Revised to automatically change
from no to yes when the form is saved. I have this
command in the on close property, but it is not working.
Do you have any suggestions.

=[Revised]=Yes
 
One difference between Open and Load is that Open can be Cancelled. Also,
there are some things that may not be ready at Open that are available at
Load. Manipulating items in the form's recordset are usually better left
until Load or later.

From the Help file:
The Open event occurs when a form is opened, but before the first record is
displayed. For reports, the event occurs before a report is previewed or
printed.

The Load event occurs when a form is opened and its records are displayed.

The order of the events is:
Open >Load >Resize >Activate >Current

When you say the "form is saved" are you making changes to the form or
records on the form? If it is records on the form and you want to set a True
value for any record that has been changed since it was first created then
in the form's BeforeUpdate event try:

If Not Me.NewRecord Then
Me.Revised = True
End If
 
Does it make a difference where I place a command in
reguards to on open and on load?

Yes; the Open event occurs first, before any controls on the Form have
been populated (or even created). The Load event occurs after the
controls are filled. If you need to look at the value of, or change a
property of a control, use the Load event.
I also want the field for Revised to automatically change
from no to yes when the form is saved. I have this
command in the on close property, but it is not working.
Do you have any suggestions.

=[Revised]=Yes

Use the Form's BeforeUpdate event instead - the user could update a
dozen records without closing the form! Click the ... icon by the
event in the Form's Properties, and choose Code Builder; Access will
give you the Sub and End Sub lines for free, you just need to add one
more:

Private Sub Form_BeforeUpdate(Cancel as Integer)
Me!Revised = True
End Sub
 
Back
Top