How to Refresh a Formset by Using Commands Outside of the Form

Last reviewed: September 21, 1995
Article ID: Q136978
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0

SUMMARY

When moving the record pointer in a table whose fields belong to an active form, the form will not refresh if the command that moved the record pointer was issued from a menu or the Command window. For example, if there is a menu item issues a SKIP command, the record pointer will move but the form will not refresh.

To have your application menu item move the record pointer and refresh the form, use the SKIP command to move the record pointer. and then use the _SCREEN.FORMCOUNT and _SCREEN.FORMS().REFRESH commands to refresh a form or formset correctly.

MORE INFORMATION

If the active form on the screen is a form and not a formset, you can use the _SCREEN.ACTIVEFORM.REFRESH command alone from the menu or Command window to refresh the form. However, if the form could be a form or a formset, it is best to make your refresh code generic, so it fits both cases.

The _SCREEN.FORMCOUNT command returns the number of forms on the screen, so it allows you to refresh each form whether a single form or a formset. Then you can use the FORMS() array to refresh each form if a formset is active. The FORMS() array is created when the forms start up. It is internal to Visual FoxPro. By putting these commands in a FOR loop, you can refresh a form or formset from a menu action.

For additional information about a form that uses toolbars, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q136277
   TITLE     : FormCount Property Does Not Count Toolbars in a Formset

Step-by-Step Example

  1. Create a formset with two pages, and place a field from a table on each page.

  2. Run the form, and place the two forms side by side.

  3. Type the SKIP command in the Command window and press ENTER. Note that the fields on each form do not change.

  4. Type the _SCREEN.FORMS(1).REFRESH command in the Command window and press ENTER. Note that the second form refreshes. This is because the name of the last form in the formset is placed in the first FORMS array element. Issuing the _SCREEN.FORMS(2).REFRESH command will refresh the other form.

  5. If the SKIP command is used in a menu, place the following code in the menu item's procedure:

    SKIP FOR x = 1 TO _SCREEN.FORMCOUNT

          _SCREEN.FORMS(x).REFRESH
    
    ENDFOR

    This will refresh any form or formset that is active at the time when the user clicks that menu item.


Additional reference words: 3.00 VFoxWin
KBCategory: kbtool kbcode
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: September 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.