How to Coordinate Parent Data Window with Child BrowseID: Q104005 2.50 2.50a | 2.00 2.50 2.50a WINDOWS | MS-DOS The information in this article applies to:
SUMMARYThis procedure below describes how to coordinate a parent data window with a child Browse window using the power tools. The screen and its controls are designed in such a way that as you move through the parent database, the parent's data is updated and so is the Browse window that displays the related records in the child database. In this example, the CUSTOMER and INVOICES databases are used to establish a one-to-many relationship. Both the CUSTOMER and INVOICES databases are located in the FoxPro TUTORIAL subdirectory. MORE INFORMATION1. Use the View window to set up a one-to-many relationship between the CUSTOMER (parent) database and the INVOICES (child) database. Select the parent database by clicking it. 2. Create a quick screen. 3. Save the environment and add the following code into the following code options in the Screen Layout dialog box: Setup Code ---------- DEFINE WINDOW child FROM 17,1 to 24,70 PANEL; FLOAT GROW ACTIVATE WINDOW child SELECT INVOICES BROWSE IN WINDOW child NOWAIT SAVE NOMODIFY LAST SELECT CUSTOMER Cleanup Code ------------ RELEASE WINDOW child Activate Code ------------- SELECT CUSTOMER 4. If you are using FoxPro for MS-DOS, choose Layout from the Screen menu, then set the screen type to Window. (In FoxPro for Windows, this step is unnecessary because the screen is a window by default.) 5. Resize the window so that it fits around the fields without leaving a lot of empty space. 6. Save the screen as TEST.SCX and then close it. 7. From the File menu, choose Open, and set the file type to Screen. NOTE: Before proceeding with this next step, make a backup of the CONTROL3.SCX and CONTROL3.SCT files (if you are using FoxPro for MS-DOS) or the CONTROL1.SCX and CONTROL1.SCT files (if you are using FoxPro for Windows). 8. In FoxPro for MS-DOS, select CONTROL3.SCX (located in your FoxPro TUTORIAL subdirectory) and then choose Open. In FoxPro for Windows, select CONTROL1.SCX (located in your FoxPro SAMPLE\ORGANIZE\SCREENS subdirectory) and then choose Open. 9. Double-click one of the push buttons on the screen and select the Valid code snippet check box. 10. The Valid code snippet is shown below. Modify the code by adding the two designated lines. The code below is from FoxPro for MS-DOS and looks slightly different in FoxPro for Windows. SET SKIP TO && Add this line DO CASE CASE act2 = 1 GO TOP CASE act2 = 2 SKIP -1 IF BOF() GO TOP ENDIF CASE act2 = 3 SKIP 1 IF EOF() GO BOTTOM ENDIF CASE act2 = 4 GO BOTTOM CASE act2 = 5 APPEND BLANK CASE act2 = 6 CLEAR READ ENDCASE SET SKIP TO invoices && This line is optional. SHOW GETS RETURN 0 11. Save the screen as MYCONTRL.SCX. 12. From the File menu, choose Open, and then set the type to Screen. 13. Select TEST.SCX and then choose Open. 14. From the Program menu, choose Generate. 15. Choose Add. 16. Select MYCONTRL.SCX and then choose OK. 17. Choose Arrange and arrange the two screens to be toward the top of the window. Try not to overlap the screens. 18. In FoxPro for MS-DOS, choose Save from the Arrange menu. In FoxPro for Windows, choose OK. 19. Choose Generate. 20. In the Command window, issue the following command: DO test.spr Notice the three screens come up. Choosing Next from the control screen displays the updated parent screen. The related records of the child in the browse are also updated. NOTE: You can also use FOXAPP to relate two tables and accomplish the same goal. Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a foxmac KBCategory: KBSubcategory: FxprgBrowse Keywords : kbcode FxprgBrowse Version : 2.50 2.50a | 2.00 2.50 2.50a Platform : MS-DOS WINDOWS |
Last Reviewed: May 22, 1998 |