ID: Q97640
2.5x 2.60 2.60a | 2.00 2.5x 2.60 2.60a | 2.5x 2.60a
WINDOWS | MS-DOS | MACINTOSH
kbusage kbappnote
The information in this article applies to:
Although the FoxPro Screen Builder allows a data input screen to be combined with a separate Browse window, the GET fields of the data input screen and the information in the Browse window cannot be combined in a single window. However, the screen can be programmed so that the GET fields and the browse information appear to be in a single window, as explained below.
NOTE: For a more complete description of combining a Browse window with GET fields, please refer to Application Note FW1125.
For a description of Application Note FW1125 and how to obtain it, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q124606
TITLE : SAMPLE: Fw1125.exe Combines a Browse Window with Get Fields
This example uses GET fields from the CUSTOMER.DBF table in conjunction with a browse of related records in the INVOICES.DBF table. It is assumed that the CUSTOMER.DBF and INVOICES.DBF tables have been installed in the TUTORIAL subdirectory in the main FoxPro directory.
The steps below create three windows:
To create these windows using the Screen Builder power tool, do the following:
1. In the Command window, type "CREATE SCREEN getbrow" (without the
quotation marks) to create a screen using the Screen Builder.
2. From the Screen menu, choose Quick Screen. When prompted, select
CUSTOMER.DBF from the <FoxPro_directory>\TUTORIAL subdirectory, then
choose Open.
3. In the Quick Screen dialog box, select the Fields check box.
4. Move CNO and COMPANY to the Selected Fields list box. Choose OK twice
to return to the Screen Design window.
NOTE: Because the WGETS window will be defined as eight lines high,
these fields should be located in the first eight rows of the screen.
If fields are defined beyond this point, a "Position off screen" error
will be generated when the .SPR file is run.
5. FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: From the Screen menu,
choose Layout. In the Name text box, type "WGETS" (without the
quotation marks) for the screen name. Do NOT choose OK yet.
FOXPRO FOR MS-DOS: From the Screen menu, choose Screen Layout. Select
the Window option button at the top of the dialog box. In the Name text
box, type "WGETS" (without the quotation marks) for the screen name. Do
NOT choose OK yet.
6. FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: Under Options, choose the
Code button.
FOXPRO FOR MS-DOS: Skip to step 7.
7. FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: Choose both the Screen Setup
Code and Cleanup And Procedures buttons. Choose OK twice.
FOXPRO FOR MS-DOS: Under Screen Code, choose both the Setup and
Cleanup & Procs check boxes. Choose OK once.
8. Locate the "getbrow - Setup" editing window and type the following code
in it:
CLOSE DATABASES
SELECT 1
USE SYS(2004)+"\TUTORIAL\customer.dbf"
* SYS(2004) Returns the name of the directory that
* FoxPro was started from.
SELECT 2
USE SYS(2004)+"\TUTORIAL\invoices.dbf"
SET SAFETY OFF && Prevents error message if tag already exists.
INDEX ON cno TAG cno ADDITIVE
SET SAFETY ON
SELECT 1
SET RELATION TO cno INTO invoices ADDITIVE
SET SKIP TO invoices && Establishes one-to-many relationship.
DEFINE WINDOW wbig FROM 1,1 TO 22,80 DOUBLE
DEFINE WINDOW wgets FROM 0,5 TO 8,75;
IN WINDOW wbig NONE
DEFINE WINDOW wbrowse FROM 9,0 TO 20,80;
IN WINDOW wbig NONE
ACTIVATE WINDOW wbig
SELECT invoices
ACTIVATE WINDOW wbrowse
BROWSE WINDOW wbrowse IN WINDOW wbig SAVE NOWAIT
SELECT customer
ACTIVATE WINDOW wgets
9. Type the following code in the "getbrow - Cleanup" editing window:
RELEASE WINDOW wbig, wbrowse
10. From the Program menu, choose Generate.
11. When prompted to save changes to the file, choose Yes.
12. When prompted to save environment information, choose No.
NOTE: The environment is controlled by the code in "getbrow - Setup" in
Step 8.
13. FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: In the Generate Screen
dialog box, choose the More button.
FOXPRO FOR MS-DOS: Skip to step 14.
14. Clear the Define Windows check box, then choose Generate.
To run the program, type "DO getbrow.spr" (without the quotation marks) in the Command window.
NOTE: No records are displayed in the Browse window of this example because the first record in the CUSTOMER table doesn't have any related INVOICES records. To move through the tables so that you can see other records, add the control buttons described in the next section.
To create push buttons to move forward or backward through the tables, or to close the screen, perform the following steps:
1. Type "MODIFY SCREEN getbrow" (without the quotation marks) to open the
screen.
2. To place a push button object on the screen immediately below the
COMPANY GET field, do one of the following:
FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: From the toolbox, choose the
push button tool. Click the area directly below the COMPANY GET field to
place the push button object.
FOXPRO FOR MS-DOS: From the Screen menu, choose Push Button.
NOTE: The push button object must not overlap the areas used by the
WGETS or WBROWSE windows.
3. Under Push Button Prompts, type "Next", "Prior", and "Quit" (without
the quotation marks) on separate lines. In the Variable text box, type
"BUTVAL" (without the quotation marks). Do NOT choose OK yet.
4. FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: Under Clauses, choose the
Valid button.
FOXPRO FOR MS-DOS: Under Options, select the Valid check box.
5. Verify that the Procedure option button is selected, then type the
following code in the text box:
SELECT customer
SET SKIP TO && Removes one-to-many relationship so that the SKIP
* statement below doesn't move through the INVOICES
* records.
DO CASE
CASE butval = 1
IF (!EOF())
SKIP 1
ENDIF
CASE butval = 2
IF (!BOF())
SKIP - 1
ENDIF
CASE butval = 3
CLEAR READ
ENDCASE
SET SKIP TO invoices && Reestablishes one-to-many relationship.
SHOW GETS
6. Choose OK twice to return to the Screen Design window.
7. FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: Skip to step 8.
FOXPRO FOR MS-DOS: Drag the push button to a location immediately below
the COMPANY GET field.
8. Generate the code for the screen again. Be sure to clear the Define
Windows check box.
NOTE: Not all CUSTOMER records have corresponding INVOICES records. Also,
note that "Atec Data Service" is the first CUSTOMER record that has
multiple related INVOICE records.
Two keyboard methods can be used to switch between the Browse window and the GET screen:
-or-
a. Type "MODIFY SCREEN getbrow" (without the quotation marks) to
open the screen.
b. From the Screen menu, choose Open All Snippets.
c. Locate the "getbrow - Setup" editing window, then add the following
as the first two lines of code:
SET SYSMENU ON && Enables CTRL+F1 to switch.
ON KEY LABEL F2 DO switchwin && Enables F2 to switch.
d. In the "getbrow - Cleanup" editing window, add the following as the
last lines of code:
ON KEY LABEL F2 && Clear the F2 key when done.
PROCEDURE switchwin
IF WONTOP('WGETS')
SELECT customer
ACTIVATE WINDOW wbrowse
BROWSE WINDOW wbrowse IN WINDOW wbig SAVE NOWAIT
ELSE
SELECT invoices
ACTIVATE WINDOW wgets
ENDIF
e. Generate the code for the screen again. Be sure to clear the Define
Windows check box.
In this example, the F2 key is used to switch between windows using the
procedure SWITCHWIN. This procedure determines which window is currently
the active output window and activates the other window. This method
does not require access to the menu bar, and will cycle only between the
GET screen and the Browse window.
Keywords : kbcode FxtoolSbuilder
Version : 2.5x 2.60 2.60a | 2.00 2.5x 2.60
Platform : MACINTOSH MS-DOS WINDOWS
Last Reviewed: May 22, 1998