By Barry Rochford
Stop for a second and think how you usually design an Input Form for a Set having a Child Table. You probably drop & drag an embedded Browse Object for the Child Table. You dress up the form, add some buttons, save it and then start entering some Test Data. Alpha Five automatically places the linking field into each new Child Record.
Now, assume the Child Record has to be linked to the Parent by two fields, let's say "Invoice_num" and "Project_Id". Now you are back to Form Design. Your first hint that something has gone awry appears when you drag and drop an embedded Browse Object for the Child onto your Form. What's this! Both the "Invoice_Num" and the "Project_Id" fields appear on the Browse! Well, that's certainly strange isn't it? With that sinking feeling and your stomach acids churning about, you page through your manual to the explanation of "Linking Fields" it even shows an example using two fields. Wait just a second, what's that NOTE say? "If you use more than single field in the Linking Fields boxes, you cannot use referential integrity." The bottom line is that Alpha Five is not going to automatically enter either of the Linking Fields into your Child Records.
Figure 1 DW_Header Record Layout
Figure 2 DW_Invitms Record Layout
Figure 3 DW_Inv_set Set Design
Figure 4 Entry Form
Well, all is not lost there are 3 ways that I know of to handle this situation:
Save the field rules and now back at the Control Panel, Right-click on DW_Invitms, again Edit structure, add a new field to the end of the table, again call it "Link" Character type with a length of 10. Save the change, close the Restructure Window and Right-Click on DW_Invitems again and select Edit Field Rules. Now we want to take care of our two "real" Linking Fields, so select the "Invoice_num" Field. On the Field Type Tab, click "Calculated", then enter the following expression:
Left(Link,5)Now do the same thing for the "Project_Id" field, but use this expression:
Substr(Link,6,5)Save the Field Rules and then let's go back to our Set. Right-click on DW_Inv_Set, select Edit Set. Highlight Dw_Invitms, click on Edit Link. Change the original Linking Field to "Link". Save the changes and now go to the Entry Form in design mode. The two Fields that we fixed need not display on the Browse so we will delete them. Right-click on the browse, move your mouse to the first field to be deleted, click so it is selected, press Delete. Do the same for the second field, save the Form and we are ready to test the validity of our changes.
Figure 5 Entry Form after Changes
If you need to Link using a Character and a Date field, no problem, use the CDATE() Function in your expression. Just don't forget to convert it back to a Date type field in your Field Rule. Same for using a Numeric type field - use the STR() Function.
Barry Rochford is an Alpha Developer located near Newtown, PA. He can be reached at brochford@enter.net
6/10/99
Don't forget, we need your feedback to make this site better!