Presentation is loading. Please wait.

Presentation is loading. Please wait.

Entering Data in One of the Independent Entity Tables and the Associative Entity Table of a M:M Relationship* If you came to this presentation via a web.

Similar presentations


Presentation on theme: "Entering Data in One of the Independent Entity Tables and the Associative Entity Table of a M:M Relationship* If you came to this presentation via a web."— Presentation transcript:

1

2 Entering Data in One of the Independent Entity Tables and the Associative Entity Table of a M:M Relationship* If you came to this presentation via a web browser, right-click and choose “Full Screen” before proceeding. Click mouse or press space bar to continue. This presentation was prepared by Professor Steve Ross, with the advice of other MIS Faculty, for use in MIS Classes at Western Washington University. Please contact Dr. Ross for permission to use in other settings..Dr. Ross

3 The Goal : Edit Buildings and Assignments to the Buildings

4 tblAssignment BuildingID WorkerID StartDate tblBuilding BuildingID Address City State Zip Description Status ManagerID BuildingType tblWorker WorkerID LastName FirstName MidName AnnualPayIn1000 RankID SupervisorID DepartmentID MailCode The Challenge The data comes from two different tables –tblBuilding –tblAssignment –You cannot edit data from two tables on the same form.

5 tblAssignment BuildingID WorkerID StartDate tblBuilding BuildingID Address City State Zip Description Status ManagerID BuildingType tblWorker WorkerID LastName FirstName MidName AnnualPayIn1000 RankID SupervisorID DepartmentID MailCode The Solution In a 1:M relationship, represent … –the 1-side as the main form –The M-side as the subform Record Source for the main form Record Source for the subform

6 Step 1 – Source Data The standard for this course is to use a view as the Record Source of each form. For any form that enables the user to edit data, the view must be based on a single table only. Therefore Step 1 is to create a view for each form. –vueFrmBuilding and vueSfrAssignment contain all fields of their respective tables

7 Step 1a – Source Data Determine how each field from vueFrmBuilding will appear on the “1-side” form. (Note: “controls” are objects on the form, such as labels, textboxes, buttons and combo boxes.) FieldEditableControl format Constraints BuildingIDNoRead only text AddressYesText box CityYesText box StateYesText box ZipYesText box DescriptionYesText box StatusYesText box ManagerIDYesCombo box FK to tblWorker BuildingTypeYesText box

8 Step 1b – Source Data Do the same for vueSfrAssignment – the “M-side” view *The foreign key in the subform, vueSfrAssignment.BuildingID, always matches the value of the parent form linking field (vueFrmBuilding.BuildingID) on the main form. Therefore, an editable or visible control is not needed on the subform for the FK field. FieldEditableControl formatConstraints BuildingIDNoNo control needed*FK to tblBuilding WorkerIDYesComboFK to tblWorker StartDateYesText box

9 Just one more slight complication: tblAssignment does not contain any Worker Names, it contains WorkerIDs. How do we show names instead? 15 37

10 The Complication : the Worker is a number (WorkerID) in the tblAssignment The Solution: Use a combo box to look up and show the Worker Name corresponding to the WorkerID

11 Standard Form Heading Step 2 – Layout Create a draft view of the form, giving approximate placement and type of controls for each data item I usually do this by hand, not in a graphic program such as this BuildingID (read only, no label) Address: City: State: Zip: Description: Status: Manager: Person list combo box Address City Description Status State Zip Assignments Person Start Date These will be text boxes bound to the relevant fields Person list combo box StartDate These will be combo boxes, bound to the relevant fields but displaying data from the related tables

12 Step 3a – Create Version 1 of the Main Form Create the main form –Use the “1-side” view created in Step 1 (vueFrmBuilding) as the record source –Add all desired fields to the form

13 Step 3b – Add the Subform There are multiple ways to create a subform. 1.From Scratch Build and save a form to use as the subform. Drag the subform from the Forms object window into the Details area of the main form Set …. –The Link Master Fields and –The Link Child Fields … to the appropriate PK and FK (e.g. BuildingID)

14 Step 3b – Add the Subform 2.With the subform button and wizard Use the “M-side” view as the record source Notice that the PK and FK fields are the link between the main form and the subform. –“Parent” or “Master” (PK) field on the left –“Child” (FK) field on the right

15 Step 3b – About the Subform Control Illustrated below is … A subform (It’s everything inside the orange box) A subform control (It is the orange box) –The subform control manages the link between the main form and the subform

16 Step 3b – About the Subform Control The Subform Control is selected (orange box) The Subform is selected (notice the black dot)

17 Step 3b – About the Subform Control The Data properties tab shows … the Link Master Fields and the Link Child Fields The linkage is good The linkage is broken

18 Step 3c – Subform Layout Normally, you will have to do additional formatting of the subform.

19 Step 3c – Subform Layout Set the subform Default View to Continuous Forms.

20 Step 3c – Layout Comparison Side-by-side ComparisonEfficientWasteful NeatMessy Data View

21 Step 3c – Layout Comparison Side-by-side ComparisonEfficientWasteful NeatMessy Data View

22 Step 4a – Fine Tuning, Main Form Convert text boxes to combo boxes or other controls as necessary* * See this presentation for discussion of technique.this presentation

23 Step 4b – Fine Tuning, Subform Open the subform in design view Convert text boxes to combo boxes or other controls as necessary Change the Default View to Continuous Forms –Set Dividing Lines and Record Selectors to “yes” Important settings

24 Step 4c – Finish the Forms Apply check constraints and other properties to controls. Once controls are set, apply other design standards.* * The form illustrated met all MIS 421 design standards when it was created. Subsequent changes to the standards may have occurred.

25 Trouble Shooting Common Problems Do all the records from the M-side table show in the subform … no matter what record is on the main form? See “Broken Linkage” slide below. Does the Combo Box for a FK field look like it is set up correctly, but you still cannot enter or change the Combo Box entry? See “Too Many Tables in Your View” slide below.

26 Trouble Shooting Broken Linage Sometimes the linkage is broken. Building 1 actually has only two assignments, but all assignments are appearing on the subform.

27 Trouble Shooting Too Many Tables in Your View Sometimes the Combo Box does not allow you to change the value in the Combo Box – even though the Combo Box appears to be set up correctly. –The most likely cause is that the view for the Form or the view for the Subform is based on more than one table. There should be just one table supporting the Main Form and one supporting the Subform. Delete unneeded tables from the view.

28 The Chicken or the Egg You are asked to enter this new information. –New Building: Address 123 Cherry Lane City: Demingway State: WA ZIP: 99999 –New Worker: Name: Joe Blaineless –New Assignment: Joe is assigned to the new Demingway building on Jan 1, 20xx Which data requires an additional form? Which data must be entered first? Last?

29 Step 5 – Quality Assurance Can the user change data in an existing record –in the “1-side” view? –in the “M-side” view? Can the user enter new records –in the “1-side” view? –in the “M-side” view? Are all constraints working properly? (Test the limits.) Have all Design Standards been met?


Download ppt "Entering Data in One of the Independent Entity Tables and the Associative Entity Table of a M:M Relationship* If you came to this presentation via a web."

Similar presentations


Ads by Google