ACC: Form OnOpen Property May Not Set Unbound Control ValuesID: Q90146
|
Moderate: Requires basic macro, coding, and interoperability skills.
In Microsoft Access version 1.x, if you have unbound controls on a form or
report that you want to set with a macro called from the OnOpen property,
that macro should include a GoToControl or GoToRecord action before the
SetValue action(s). The OnOpen property is triggered when the form or
report opens, before the first record is displayed. When the OnOpen
property is triggered, there is no current record or control to set. You
must have a current record or control before Microsoft Access can set any
controls on a form or report.
In Microsoft Access version 2.0, the timing of events on forms is changed
slightly, making it possible to run a SetValue action without a
GoToControl or GoToRecord action preceding it. The OnOpen timing for
reports is not changed, however, and a GoToControl or GoToRecord action is
still necessary.
This behavior no longer occurs in Microsoft Access version 7.0.
In version 1.x, the OnOpen property for forms and reports is triggered
when the object is opened, but before there is a current record. To force
the focus to a specific control in order to set its value before the first
record is displayed, insert a GoToControl or GoToRecord action before the
SetValue action in the macro called from the OnOpen property.
If the controls' values are to come from a specific record, use the
GoToRecord action in your macro before the SetValue action. If you want to
set the value of individual controls, use the GoToControl action.
Actions such as GoToControl or GoToRecord, by default, refer to the object
calling the macro. Therefore, the Item action argument for each
GoToControl and SetValue action need only contain the ControlName (or
Name, in version 2.0) of the control whose value you want to set.
For more information about the OnOpen property, search for "OnOpen," and then "OnOpen, OnClose Properties" using the Microsoft Access Help menu.
Keywords : kbusage FmsEvnt
Version : 1.0 1.10 2.0
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: March 11, 1999