How to Link List popup Display to Value of @...GET

Last reviewed: January 18, 1996
Article ID: Q142737
The information in this article applies to:
  • Microsoft FoxPro for Windows, version 2.5, 2.5a, 2.5b, 2.6, 2.6a
  • Microsoft FoxPro for Macintosh, version 2.5b, 2.5c, 2.6a

SUMMARY

To forestall having to scroll through a long list in order to find recurring instances of a given value in a table (.dbf file), you can choose to type the desired value in an @...GET field and issue a LOCATE FOR command to find the first such instance, and then use a CONTINUE command to find other instances.

This article gives one screen design that populates the list-popup with the contents of an array created from a SQL SELECT of the appropriate field from the table. It then coordinates the list's displayed value with the record values in the table as the LOCATE FOR and CONTINUE commands are executed.

MORE INFORMATION

Steps to Create Screen and List-Popup

  1. Set the default directory to Tutorial with the following command:

    SET DEFAULT TO SYS(2004) + "Tutorial"

  2. Create a screen by entering the following command in the Command window:

    MODIFY SCREEN TestList

  3. When the Screen Builder appears, click Screen/Layout on the menu bar.

  4. In the Screen Layout dialog box, click Code. In the Screen Code dialog box, click Screen Setup Code, and then click OK twice to expose the Setup code editing window.

  5. In the Setup code, enter the following commands:

    IF !USED("Customer")

         USE Customer in 0
    
    ENDIF SELECT Customer SELECT State,Recno() FROM Customer INTO ARRAY aTest * This assumes that no order has been set on the table Customer. * If the table is ordered the SELECT - SQL must include an * ORDER BY clause to place the query results in the same sequence as * that of the table. A further assumption is that the SELECT will not * include other numeric fields. Other character fields may be * included. Locater = "" && memvar tied to @...GET

    Close and save the Setup snippet by pressing CTRL+W

  6. Click the GET ('ab') tool on the Screen designer toolbar. Place a GET field text box on the screen, and in the ensuing Field dialog box, type Locater in the edit box to the right of the Input button.

  7. Click the Valid button, and then click inside the edit region of the Code Snippet window. Enter the following commands:

    LOCATE FOR State = ALLTRIM(UPPER(locater)) Lookup = ASCAN(aTest,Recno()) && local variable = locate's recno() mylist = ASUBSCRIPT(aTest,Lookup,1) && position list's display SHOW GET mylist

    Click OK twice to return to the screen. Size the @...GET text box to permit data entry.

  8. Click the List tool (ninth from the top) and click the screen to position the list. In the List dialog box, select the From Array option, and type aTest in the edit box to the right. To the right of the Variable button, type mylist in the edit box. Click OK to return to the screen, and size the List so that it will display several lines of values.

  9. Click the Push Button tool (fifth from the top), and place a button on the screen. In the Push Button dialog box, type Continue in the Push Button Prompts text editing region. To the right of the Variable button, type Go_On or some other variable name for the button object. Click the Valid button, and in the Code Snippet window, click the Procedure edit region, and enter these commands:

    CONTINUE Lookup = ASCAN(aTest,RECNO()) && Local variable = locate's Record# mylist = ASUBSCRIPT(aTest,Lookup,1) SHOW GET mylist

    Click OK twice to return to the screen.

  10. On the Program menu, click Generate, and proceed through the steps

        to generate a screen program named TestList.spr from the screen
        definition TestList.scx.
    

  11. In the Command window, type the following command:

        DO TESTLIST.SPR
    

  12. In the screen, enter the expression ca in the @...GET text box, press

        the ENTER key, and observe the list's display. Click the Continue
        button and observe the list's display. Notice the display of the record
        number on the status bar.
    


Additional reference words: 2.50 2.50a 2.50b 2.50c 2.60 2.60a FoxWin FoxMac
textbox listbox
KBCategory: kbprg kbhowto
KBSubcategory: FxprgGeneral


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