How to Create a Custom Search Screen
The information in this article applies to:
- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a
- Microsoft FoxPro for Windows, versions 2.5, 2.5a
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.
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:
- Create a quick screen.
- Select the Use Memory Variables check box on the first screen.
- Choose OK.
- Create a push button that says "End Search Screen". Be sure that the variable you assign it doesn't match a field name.
In the VALID clause of the End Search Screen push button, input the following procedure: '
CLEAR READ && Terminate Screen
- 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.
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
*****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
SKIP 1 && Skip to the next record.
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
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.
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.
*****IF THE RECORD WAS NOT FOUND,
*****BLANK THE MEMORY VARIABLES OUT AND DISPLAY NOTHING.
SCATTER MEMVAR BLANK
WAIT WINDOW 'THE SPECIFIED CNO WAS NOT FOUND.'
- From the Screen menu, choose Layout (in FoxPro for MS-DOS, choose Screen Layout).
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 query words: FoxWin FoxDos 2.x screen search locate function
Keywords : kbcode FxenvMemory
Version : 2.00 2.50 2.50a | 2.50 2.50a
Platform : MS-DOS WINDOWS
Issue type :