Microsoft Access Tutorial
|
|
|
|
| Articles Reviews Microsoft Access | |
| Written by Adi Bach | |
| Friday, 01 September 2006 | |
|
Page 16 of 22 Now is the time to explore some of Microsoft Access components properties. Tables, Forms, Reports and Pages properties are very rich and once you know how to use them, you can make your database better looking and more functional. We have already seen that you can control a table's looks. This is not just done for pure fantasies, sometimes it can be very useful; for example if you decide to embed a table in a good looking form, a feature we call a subform, it is better to make sure the table doesn't appear boring. Open the Music Collection6 database. Double-click the tblAlbums table to open it Datasheet view. Right-click on the Album ID column header and choose Column Width... Type 4 and click OK. On the main menu, click Format -> Datasheet... (In MS Access 97, click Format -> Cells...) In the Datasheet Formatting (Cells Effects) dialog, click the Sunken Cell Effects and click OK. On the main menu, click Format -> Font. In the Font dialog, change the font to Verdana, or Helvetica, or Tahoma (I am sure you have one those fonts, otherwise, choose any Sans Serif font, like Arial...). Set the font color to Blue (Regular, 10) and click OK. Save and close the tblAlbums table. Double-click the tblTracks table to open it Datasheet View. On the main menu, click Format -> Unhide Columns... In the Unhide Columns dialog, in the Columns list, click the Track ID, the Album Title, and the Notes check boxes to remove them. Then close the Unhide Columns dialog. On the main menu, click Format -> Datasheet ... (Format -> Cells...) Set the Cell Effects to Sunken and click OK. On the main menu, click Format -> Font... Set the font to Verdana, Blue and click OK. Right-click the Track Title column header and choose Column Width. Set the width to 36 and click OK. Save and close the tblTracks table. Design Considerations: Form properties range from the background to the header and footer sections of the form. You can use a combination of fonts, font colors, and other font styles to improve the looks of those controls and sections. Click the tblAlbums table to highlight it. On the Standard toolbar, click the New Object: AutoForm button. Switch to Design View. Select everything in the form and move it to 1/4 horizontal and 1/8 vertical rulers. Enlarge the Album ID label so that its right border aligns with 1. Select all the labels, only the labels (and without the subform), then right-click any of the highlighted labels and choose Size -> To Widest. Select the AlbumID text box and move it to 1 1/8 horizontal ruler. Select all the text boxes (without the subform). Right-click any of the highlighted text boxes, choose Align -> Left. Resize the AlbumID text box so that its right border aligns with 1 7/8 horizontal. Press and hold the Shift key, then click the Format and Label text boxes to select them, then release. Right-click any of the highlighted text boxes, choose Size -> To Narrowest. Click the # Of Tracks label to give it focus. Click it again to edit. Make it read Tracks. Resize the Year and Tracks labels and text boxes, then move them right of the Format and Label text boxes. Move the Notes label and text box right to the other items. (Skip this if you are using MS Access 97) Move the subform up under the other items. Switch to Form View. On the main menu, click Window -> Size To Fit Form. Save your form as frmAlbums1. The Form Header Properties: The first thing you realize about about a form is that it is made of sections: the header, the detail, and the footer sections. They are now necessary different as far as the design is concerned, it is their functionality or roles that set them apart. Open the frmAlbums2 in Design View. On the main menu, click View -> Form Header/Footer. That creates three sections on your form. On the toolbox, click the Label control. Click in the Header section and type Music Collection - Albums and press Enter. We have used the Formatting toolbar in the past to format font. Now let's explore the form and controls properties. Right-click on the new/highlighted label and choose Properties. Click the Format tab. Make sure that the Caption displays Music Collection - Albums. Set the Left property to 0.5 and the Top to 0.0833. Click the Fore Color box. An ellipsis/build button appears, click it to access the color dialog. In the Color dialog, click the Define custom Color >> button. Set the color to Red=0, Green=0, Blue=160, and click OK. For the Font Name, choose Garamond, if you don't have Garamond, choose Times New Roman, otherwise choose Georgia (or any Serif font available). Set the Font Size to 20, and the Font Weight to Bold. On the form, right-click the Music Collection - Albums and choose Size -> To Fit. Click the Form Header bar, it becomes black/highlighted. In the Properties dialog, change the Background color to Red=169, Green=211, and Blue=211. In the Special Effect, choose Raised. Save your form, then switch to Form View. When you have finished viewing the form, switch back to Design View. Control Properties: You can control properties for one control as we saw with the title, you can also control many items properties at once, as long as the items share some characteristics. Click inside the vertical ruler at dimension 1/8 and drag down to 1 1/5, that will select all items in the Detail section except the subform. In the Properties dialog, set the Fore Color to Red=0, Green=0, Blue=255. Holding the Shift key, select all the labels. On the Formatting toolbar, click the Bold button. The AlbumID text box is an AutoNumber set incrementally and automatically by the database, but sometimes it receives focus even though you can't type any value in it. So, we will make sure that it never receives focus. Click the AlbumID text box. In the Properties dialog, in the Format tab, set its Special Effect to Chiseled, its Font Weight to Bold, and its Text Align to Right. Click the Data tab. Set the Enabled to No and the Locked to Yes. Click the ArtistID box. On the Properties dialog, click the Other tab. In the Status Bar Text box, type Artist Name. In the Control Tip Text box, type Choose an Artist from the Combo Box. Click the Detail bar. On the Properties dialog, change the Back Color to Red=153, Green=204, Blue=255. Close the Properties dialog. Resize the Form Footer bar so that it is only two dotted lines down, also set its Special Effect raised. Switch to Form View. On the main menu, click Window -> Size To Fit Form. Save your form.
Form Properties: At this time, your form's title still displays something that makes it look like a table. By now you might wonder whether Microsoft Access offers the ability to create a simple dialog or only an SDI (Single Document Interface), which means the option of minimizing or maximizing the window. You make those decisions by setting specific properties for the form. Since you should still have the frmAlbums2 form displaying, switch to Design View. Double-click the button at the intersection of both rulers to access general properties for the form. On the Properties, click the All tab. Change the Caption to Music Collection - Albums. Set its Min Max Buttons to Min Enabled. Save and close the form. On the main menu, click Insert -> Form. In the New Form dialog, choose AutoForm: Columnar; in the combo box, choose tblArtists and click OK. Save the form as frmArtists. Switch to Design View. Sometimes, a small form can get lost in the midst of others; the remedy is to make sure that it always stay on top of others. You can then prevent the user from accessing any other form as long as this small form is opened. Access the general properties for the frmArtists form. On the Properties dialog, click the All tab, set the Caption to read Music Collection Artists. Set the Scroll Bars to Neither. Set the Modal to Yes (so it will always be on top, and as long as it is opened, the user cannot call another form or component). Set the Border style to Dialog (so it will look like a dialog). Since it is very important for all your forms to have a harmonized design, set the other design properties as we did for the frmAlbums form. When you have finished, switch to Form View. On the main menu, click Window -> Size To Fit Form. Save your form and close it. By the way, if you have any difficulty going back to Design View (this should be an issue only on versions prior to 2000), close the form, highlight it in the Database Window, and click the Design button in the Database Window.
Tabular Form: You will quickly realize that there are situations when the tabular is more appropriate that the columnar forms. The tabular table is usually used to join data originating from two or more tables; no, it is not like a query. And a tabular form is built from a join table, like the Tracks form we need to build. In the Database Window, click the Queries object button then double-click Create Query In Design View. From the Show Table property sheet, double-click tblTracks and click Close. In the tblTracks list, click AlbumID, press and hold Shift, then click TrackLength. Drag any of the highlighted items to the first field in the query. Save the query as qryTracks and close it. On the Standard toolbar, click the New Object button arrow and choose Form. In the New Form dialog, choose AutoForm: Tabular; in the combo box, choose qryTracks and click OK. Save your new form as frmTracks. Switch to Design View. Resize your form so it can fit easily on your screen. Remember to coordinate the colors with the other forms. Play with the controls and different properties until you get an acceptably professionally good lovingly form.
Techniques of Designing Forms: The techniques you use to make you forms look better depend on various factors raging from the capacities of the software, your mood and inspiration of the day, your customer's taste, etc. Nevertheless, it doesn't hurt to experiment and found out what is available in Microsoft Access design. Open the Georgetown Cleaning Services4 database. On the main menu, click Insert -> Form. On the New Form dialog, accept Design View; in the combo box, select tblCleaningOrders. Click OK. Save the form as frmCleaningOrders. Make sure you have the Properties dialog on your screen, the Toolbox, and the Field List. Right-click on the form in Design View and choose Form Header/Footer. Leave the form design view open. From the Database Window, open the frmCustomers1 form in Design View. In the Header section, click inside the vertical ruler and drag to cover the title and the company address label, that will select them. Right-click on the selected items and choose Copy. Close the frmCustomers1 form. Right-click in the Header section of the frmCleaningOrders form and choose Paste. With everything still selected, move the selection 1 division right. Right-click somewhere on an empty area of the Header section, that will unselect everything but highlight the Header bar indicating that the section is deselected. From the Properties, set the Back Color to 9816831 with a Raised Special Effect. Give the same color and same Special Effect to the Footer section. Click anywhere in the Detail section. From the Properties, set the back Color to 14544639. Drag the OrderID from the Field List to the most right part of the Header section. With the OrderID still selected, set its Enabled field to No, its Locked field to Yes, its Special Effect to Chiseled, its Font Weight to Bold, and its Font color to blue; also change its label's font color to blue. Drag EmployeeID from the Field List to the space under OrderID. Drag all the other items to the Detail section. Arrange them to your taste.
Open the frmCleaningOrders1 form in Design View. Click the Rectangle from the Toolbox and draw a rectangle that covers all the top three text boxes and their labels on the top Detail section. Set the rectangle's Special Effect to Raised. Draw another rectangle that will cover all but only the cleaning items. Set its Special Effects to Raised. Draw one more rectangle that covers the Notes box and its label. Draw one last rectangle that will cover everything in the Detail section. Set its Back Color to 9816831 and its Special Effect to Sunken. Using the Object combo box on the Formatting toolbar, select each of the first created rectangle and on the main menu click Format -> Send to Back. Do it also for the largest rectangle. If the smaller rectangles don't seem to have the right Back Color, set it to 14544639.
|
|
| Last Updated ( Friday, 02 January 2009 ) | |
| < Prev |
|---|












