|
|
Step Number 1Now we are going to create a form with a subform. This speeds data entry and keeps you from having to open numerous child forms in order to edit related data. First, we need to fix the Recipes table so that it has a few more fields on it. Right click on tblRecipes and select Design View from the menu that drops down. Step Number 2You should remember how to add fields to add table from the earlier tutorials. Do so, until you have the fields shown below in the Recipes table. Step Number 3Now, close and save the table. Once you are back to the database window, click on Forms to bring up a list of the forms in this database project. Select Create Form by Using Wizard. Step Number 4You should recognize this first window of the Form Wizard. Select tblRecipes in the combo box Step Number 5Select all of the fields in this table to display on the form. Step Number 6Select tblRecipeIngredients. You don't actually want to add any of these fields, since it is the linking table between the Ingredients table and the Recipes table. Step Number 7Now select tblIngredients from the combo box and add the IngredientName field to the form. Then click Next. Step Number 8In the next window, make sure that you have the form displaying your data by tblRecipes. The recipes table is the master table, while the ingredients table is the child table (meaning that your form will display only the records in the ingredients table that correspond to a given record in the Recipes table). Be sure that the Form with subform(s) option is selected. Click Next. Step Number 9In the next step of the wizard, Access will ask you about the layout you want for the subform. Be sure that you have selected the Tabular layout. Click Next. Step Number 10For the form style, I chose standard. I personally find background http://academic.lipscomb.edu/access/images to be distracting. However, you may choose a different style if you find one that you like. Click Next Step Number 11In the next window that comes up, be sure that you have named your form frmRecipes and your subform frmRecipeIngredients. Now, click Finish. Step Number 12Access produced a form that doesn't look too bad, but you may need to move some things around to make it look right. We'll fix these things next. Step Number 13Switch to design view. You should see the window below. We need to fix the spacing on several of the control labels and also fix the size of the subform (Access messes this up more often than it gets it right, so you should make sure you are familiar with moving and resizing controls - it will only get worse when you work with multiple subforms). Step Number 14Since you have already worked with designing forms manually, it should be a fairly simple matter for you to rearrange the controls on the form (and resize the form) until it looks like the image below. Step Number 15We also need to rearrange the controls on the subform. It should be IngredientName, Quantity, then Comments. Access didn't do this very well either, but at least it set up the subform and put the controls in place. You can rearrange these controls the same way you did when manually designing a form, but you will need to drag the labels separately from the fields, since they are in different parts of the form. Step Number 16Now take a look at the form in View mode. It looks a lot better than it did before, but we still need to modify it to make it look right. Switch back to design view. Step Number 17Right-click in the little box in the upper left hand corner of the subform, as shown below and select Properties from the popup menu. Step Number 18Find the item labeled Navigation Buttons and set it to No. Step Number 19Do the same for dividing lines, since they serve no useful purpose. Step Number 20Try clicking on the subform now. Note that the properties in the properties window are different now. The window now contains the properties of the subform and its label as a unit, rather than just the subform itself. We aren't going to do anything with this, I just thought it important that you take a look at what was there, in case it ever shows up when you were intending to work on just the subform. Step Number 21Now click on the square in the upper left corner of the Recipe form. The data in the properties window will change again. Now we can start editing the properties of the main form to make it look better. Step Number 22First, take out the dividing lines. No one knows why Access puts those there; they only seem to clutter the form. Step Number 23Next, select Scrollbars and tell it that you don't want any. Why would you, on a form that displays only a single record at a time. Step Number 24Now, we will continue working on the subform. First, click on the subform and find the Border Style property. Change it to Transparent, since we really don't want a wierd-looking border around our subform anyway. Step Number 25Now, open the form in view mode. Doesn't look too bad now, does it? In fact, it looks quite professional. This was very easy to do by just using the wizard and then fixing the positions of a few controls. Step Number 26Now, close the form and save your changes. |