PRB: Wrong Form Name Returned in Opentables Event

Last reviewed: April 30, 1996
Article ID: Q129227
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows version 3.0

SYMPTOMS

When using the PROGRAM() function to verify the method of a form that is being executed, you notice that the name of the form is incorrect in the Opentables Event and BeforeOpenTables event of the Data Environment.

The PROGRAM() function returns FORM.DATAENVIRONMENT.OPENTABLES when it is called from the OpenTables and FORM.DATAENVIRONMEMT.BEFOREOPENTABLES when it is called from the BeforeOpenTables. If the name of the form is FORM1, the PROGRAM() function should return FORM1.DATAENVIRONMENT.OPENTABLES and FORM1.DATAENVIRONMENT.BEFOREOPENTABLES.

CAUSE

The OpenTables and BeforeOpenTables events are executed before the properties of the Form object are set. The PROGRAM() function uses the Name property of the object. Because the Name property of the form has not been set yet, the PROGRAM function uses the default name (Form).

STATUS

This behavior is by design.

MORE INFORMATION

The PROGRAM() function returns the name of the currently executing program. It can also return the name of the method that is currently executing. You can use the PROGRAM() function as a debugging tool in the Debug window.

Steps to Reproduce Behavior

  1. Create a form

  2. Right click and select the Data Environment from the popup. Add the SAMPLES\DATA\CUSTOMER table to the Data Environment.

  3. Select the Data Environment object in the Properties sheet and place the following code in the OpenTables, BeforeOpenTables, CloseTables, and AfterCloseTables events of the DataEnvironment:

    ACTIVATE SCREEN ?PROGRAM()

  4. Save and run the form. The name of the method currently running is printed on the desktop.


Additional reference words: 3.00 VFoxWin
KBCategory: kbtool kbprb
KBSubcategory: FxtoolFormdes


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 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.