How to Create a Custom Search Screen

Last reviewed: April 29, 1996
Article ID: Q100564
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SYMPTOMS

You can create a customized search screen by creating a quick screen with an End Search Screen push button, as illustrated in the example below.

MORE INFORMATION

This example uses the CUSTOMER database located in the FoxPro TUTORIAL subdirectory and assumes that the database is indexed on and the order is set to the CNO field in the CUSTOMER database. In this screen, once a CNO number (customer number) is entered, the database will be searched for the corresponding record(s). The information in the record will be displayed, and you can press a key to move to the next record that has the same CNO number, if it exists. To quit, choose the End Search Screen button.

To create this customized search screen, do the following:

  1. Create a quick screen.

  2. Select the Use Memory Variables check box on the first screen.

  3. Choose OK.

  4. Create a push button that says "End Search Screen". Be sure that the variable you assign it doesn't match a field name.

  5. In the VALID clause of the End Search Screen push button, input the following procedure:

          CLEAR READ     && Terminate Screen
    
    

  6. Double-click each field except the CNO field and select the Say and Refresh options. This enables all the fields to be displayed, but only the CNO field that is used to enter the customer number that will be searched for in the database may be edited.

  7. In the VALID clause of the M.CNO field, input the following procedure:

          SEEK ALLTRIM(m.cno)  && Find first CNO in the database equal to
    
                               && M.CNO.
    
          *****IS THERE A RECORD WITH THIS CNO IN THE DATABASE?
          IF FOUND()           && If a record with the CNO exists,
            SCATTER MEMVAR     && read record into memory variables and
            SHOW GETS          && refresh the SAY fields that use the
                               && memory variables.
            WAIT WINDOW 'PRESS TO SEE NEXT RECORD.'
    
            *****CODE TO DEAL WITH MULTIPLE RECORDS WITH SAME CNO
            *****NUMBER
            SKIP 1                   && Skip to the next record.
            oldcno=m.cno
            SCATTER MEMVAR           && Get the new M.CNO.
            DO WHILE oldcno = m.cno  && Is the next record's CNO equal to
                                     && the previous?
              SHOW GETS              && Refresh the SAY fields with new
                                     && information.
              WAIT WINDOW 'PRESS RETURN FOR NEXT RECORD.'
              SKIP 1                 && Go to the next record and repeat
                                     && same process until there are no
                                     && more records with the CNO number.
              oldcno=m.cno
              SCATTER MEMVAR
            ENDDO
            m.cno=oldcno             && Only show the old CNO number.
            WAIT WINDOW 'NO MORE RECORDS FOUND WITH CNO:'+oldcno
            *****END OF CODE THAT IS NEEDED FOR MULTIPLE RECORDS*****
    
            RETURN                && Return control to screen and don't
                                  && execute the code below.
          ENDIF
    
          *****IF THE RECORD WAS NOT FOUND,
          *****BLANK THE MEMORY VARIABLES OUT AND DISPLAY NOTHING.
          SCATTER MEMVAR BLANK
          SHOW GETS
          WAIT WINDOW 'THE SPECIFIED CNO WAS NOT FOUND.'
    
    

  8. From the Screen menu, choose Layout (in FoxPro for MS-DOS, choose Screen Layout).

  9. In FoxPro for Windows, choose the Screen Setup Code button. In FoxPro for MS-DOS, select the Setup check box. In the setup code for the screen, type the following:

          SCATTER MEMVAR BLANK
    


Additional reference words: FoxWin FoxDos 2.00 2.50 2.50a 2.x screen search
locate
function
KBCategory: kbenv kbprg kbcode kbui
KBSubcategory: FxenvMemory


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