Microsoft KB Archive/90812

{|
 * width="100%"|

PRB: Cannot Refer to Record in OnClose Property Function
'Article ID: Q90812

Creation Date: 22-OCT-1992

Revision Date: 19-SEP-1996' The information in this article applies to:


 * Microsoft Access versions 1.0, 1.1

SYMPTOMS

If you attempt to refer to the last record that was displayed by a form in a function or macro that was triggered by the OnClose property of the form, instead of receiving information about the last record that was displayed, you will receive information about the first record of the bound table or query.

CAUSE

This behavior occurs because the Close event is the last action that occurs before the form is closed. By the time the Close event occurs, the form has released its pointer to the record in the bound query or table and can no longer refer to it. If you were stepping through the macro or code that was called by the OnClose property, you would still see the information in the form, but because the pointer to that data no longer exists, you would not be able to gain access to that data.

RESOLUTION

If you need to refer to the last record that was displayed by a form prior to closing, you will need to use a method that uses another form or Microsoft Access Basic code to maintain a duplicate copy of the current record that is displayed in the form. The macro or function that does this should be called by the form's OnCurrent event so that every time you change the record information, the macro makes a copy on the separate form or in Microsoft Access Basic variables. Then, when the OnClose property is triggered, your macro or function can use the data on the separate form or in the Microsoft Access Basic variables because they will still be available.

STATUS

This behavior no longer occurs in Microsoft Access version 2.0.
 * }

-

"THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED &quot;AS IS&quot; 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." '' ©1997 Microsoft Corporation. All rights reserved. Legal Notices.

''

Additional reference words: 1.00 1.10

KBCategory: kbusage

KBSubcategory: FmsEvnt