ACC: Form OnOpen Property May Not Set Unbound Control Values

Last reviewed: April 2, 1997
Article ID: Q90146
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0

SUMMARY

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.

MORE INFORMATION

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.

REFERENCES

For more information about the OnOpen property, search for "OnOpen," and then "OnOpen, OnClose Properties" using the Microsoft Access Help menu.


Keywords : FmsEvnt kbusage
Version : 1.0 1.10 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.