Lesson 11_ Data Controls

12
 Data Controls  Label Ads by Google   Access 2007  Office 2007   VB Net Tutorials  Microsoft 2007  Introduction A label is a control that serves as a guide to t he user. It provides a static text that the user cannot change but can read to get information about another contr ol on the form or r eport. You can also use it to displa y simple information to the user. Mos t co ntro ls on the form or the report are not explicit at first glance and the user would not know what they are. Therefore, you can assign a label to the control as a help to the user. To add a label to a form or report, in the Controls section of the Ribbon, click Label and click on the form or report. Type the text that the label will di sp lay and pr ess Enter (as we will see, mo st controls add their own label to the form or report).  Practical Learning: Introducing Data Controls Start Microsoft Access and open the Red Oak High School database you created in Lesson 5 1. On the Ri bb on, click Create and, in th e Forms section, click Form Desig n 2. In the Properties window, click the Data tab and set the Record Source to Stu dents 3. Save the form as Students and close it 4. Properties of a Label Probabl y the most import ant and the mo st obvious character isti c of a label is the text it is displaying. The text is the label's caption. If you click the Label control on the Ribbon and click the form or report, you must first define its caption. If a label already has a caption, there are various ways you can edit it. For example, you can double-click it to access its Properties window and edit the string in the Caption field. On the other hand, to edit the caption of a label, on the form or report, click inside the label. That would put it into edit mode and you can edit it as you wish. The appearance o f a label i s visibly controlled by its font characteristics. The Font name, also called its face, is the name of the font as defined by the . We saw that there are various ways you can define the font characteristics of a control like th e label. The size of a label control its Width and its Height. Although the dimensions are closely related to the font charact eristic s, they can be indep ende ntly def ined. There are two main ways you can resize a label, which is equivalent to changing its size. To set your own size, in the Format tab of the Properties window of the label, change the values of the Width and Height prope rties. U nless you plan to show the background color of a label, probably the best way to resize a label is to make it adjust to the dimensions depending on the font size and the total characters width. To do this, position the mouse on one of the label's handle and double-click. The label's width and height would be set to accommodate its caption. The position of a label is controlled by its Top and Left prop erties. The Top property defines the measure from the top left corner of the section where the label i s positioned, to the top left corner of the label itself. Practical Learning: Designing Labels From the resources that accompany these lessons, open the Bethesda Car Rental1 databas e 1. operating system Microsoft Access - Lesson 11: Data Controls htt p://www.fun ctionx .com/access2007/Lesson 11.ht 1 of 12 25-Jan-2011 07:12 P

Transcript of Lesson 11_ Data Controls

Page 1: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 1/12

Data Controls

Label

Ads by Google Access 2007

Office 2007

VB Net Tutorials

Microsoft 2007

Introduction

A label is a control that serves as a guide to the user. It provides a statictext that the user cannot change but can read to get information aboutanother control on the form or r eport. You can also use it to displaysimple information to the user.

Most controls on the form or the report are notexplicit at first glance and the user would not knowwhat they are. Therefore, you can assign a label tothe control as a help to the user.

To add a label to a form or report, in the Controls

section of the Ribbon, click Label and click onthe form or report. Type the text that the label willdisplay and press Enter (as we will see, mostcontrols add their own label to the form or report).

Practical Learning: Introducing Data Controls

Start Microsoft Access and open the Red Oak High School database you created in Lesson 51.

On the Ribbon, click Create and, in the Forms section, click Form Design2.

In the Properties window, click the Data tab and set the Record Source to Students3.

Save the form as Students and close it4.

Properties of a Label

Probably the most important and the most obvious characteristic of a label is the text it isdisplaying. The text is the label's caption. If you click the Label control on the Ribbon and click theform or report, you must first define its caption. If a label already has a caption, there are variousways you can edit it. For example, you can double-click it to access its Properties window and editthe string in the Caption field. On the other hand, to edit the caption of a label, on the form orreport, click inside the label. That would put it into edit mode and you can edit it as you wish.

The appearance of a label is visibly controlled by its font characteristics. The Font name, also calledits face, is the name of the font as defined by the . We saw that there are variousways you can define the font characteristics of a control like the label.

The size of a label control its Width and its Height . Although the dimensions are closely related tothe font characteristics, they can be independently defined. There are two main ways you canresize a label, which is equivalent to changing its size. To set your own size, in the Format tab of the Properties window of the label, change the values of the Width and Height properties. Unlessyou plan to show the background color of a label, probably the best way to resize a label is tomake it adjust to the dimensions depending on the font size and the total characters width. To dothis, position the mouse on one of the label's handle and double-click. The label's width and heightwould be set to accommodate its caption.

The position of a label is controlled by its Top and Left properties. The Top property defines themeasure from the top left corner of the section where the label i s positioned, to the top left cornerof the label itself.

Practical Learning: Designing Labels

From the resources that accompany these lessons, open the Bethesda Car Rental1 database1.

operating system

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht

12 25-Jan-2011 07:12 P

Page 2: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 2/12

On the Ribbon, click Create and, in the Forms section, click Form Design2.

Right-click the form and click Form Header/Footer3.

In the Controls section of the Ribbon, click Label and click the top-left section under theHeader bar

4.

Type Bethesda Car Rental - Assets and press Enter5.

While the new label is still selected, in the Font section of the Ribbon, click the arrow of theFont combo box and select Garamond6.

Click the arrow of the Font Size combo box and select 247.

Click the Bold button8.

Click the arrow of the Font Color button and click Yellow (Standard Colors: 4th column 4 - 7throw).

9.

To resize the label, position the mouse on one of the handles surrounding the label anddouble-click

10.

Click the Form Header bar. In the Font section of the Ribbon, click the arrow of the Fill/BackColor and select Dark Red (Standard Colors: 1st column - 7th row)

11.

Click the Detail bar. In the Font section of the Ribbon, click the arrow of the Fi ll/Back Colorand select Background (Access Theme Colors: 5th column - 1st row)

12.

Save the form as Assets13.

A Title

IntroductionIn our introduction to the label control, we learned to add a string to a form. To make it act as thetitle of the form, we had put it in the header section. We also had to remember the name of theform to apply it to the label. Microsoft Access provides a faster means of creating a title. This isdone using the Title control. When you do, Microsoft Access retrieves the name of the form,creates a label, and uses the name of the form as caption.

Creating a Title

Instead of going through the label to get a title, to formally create a title, in the Controls section of

the Ribbon, click the Title control and click the form. When you click the form, if it did nothave a form header section, that section would added to the form. If it had the section, thatsection would be used. Then, a new label with the name of the form as caption would be added tothe form header section. When creating this label, Microsoft Access would use some defaultcharacteristics, such as the font name and size, and applied them to the label. Of course, you canchange any of the characteristics, including the caption of the ti tle.

Practical Learning: Adding a Title

Re-open the Red Oak High School database1.

In the Navigation Pane, under Students: Table, right-click the Students form and click DesignView

2.

In the Controls section of the Ribbon, click Title and click the form3.

As the label is still blinking, type Red Oak High School - Students and press Enter4.

While the title is still selected, in the Font section of the Ribbon, change the following

characteristics:Font: GeorgiaFont Size: 24Fore Color: BlueStyle: Bold

5.

Save the form6.

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht

12 25-Jan-2011 07:12 P

Page 3: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 3/12

A Hyperlink

Introduction

A hyperlink is a label that can be clicked to open an object of the data, an application on ,a file from the network, or a web site (or web page). Before using it, the user can position themouse on the label, which would change the cursor to a pointing finger. The user can click. Asstated already, a hyperlink can be made to open almost any type of file or document. Whencreating it, you will decide what object or file would be opened or accessed.

Creating a Hyperlink

To create a hyperlink, display a form or a report in Design View:

Press Ctrl + K

In the Controls section of the Ribbon, click the Insert Hyperlink control

A dialog box made of various sections would come up. In the left section, you can click Existing Fil eor Web Page:

In this case, if you want to open a file, click Current Folder and use the Look In combo box tospecify the folder where the file is located. Once you have specified the folder, in the large list boxin the middle-center of the dialog box, locate the file, click i t and click OK.

If you want to open a web page, you can choose one of the pages you had previously visited. To dothis, in the second column from left, click the Browsed Pages button. All the files that the dialogbox can "remember" would display in the l ist in the middle-center. You can then select the fil e. Youcan also click the arrow of the Address combo box to find out if the web site or web page you wantis in the list. If you know the web site or the web page you want the link to eventually open, typeit in the Address combo box. Once you have specified the file, click OK. This description alsoapplies if you click the Recent Fi les button.

If you want the link to open an object of the same database, such as a form or a report, in the leftcolumn, click Object in This Database. The middle-center of the dialog box would display a treeview:

computer

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht

12 25-Jan-2011 07:12 P

Page 4: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 4/12

Before selecting an object, expand its node, then select the object, and click OK.

A hyperlink is primarily a label. As such, there are some characteristics you can change for it butyou should make sure it would always be obvious to the user that it represents a hyperlink. Tochange the caption of the hyperlink, you can click it once and click it again to put it into edit mode,and edit its caption. You can also use the Properties window of the hyperlink to manage the label.

Practical Learning: Adding a Hyperlink

The Students form of the Red Oak High School database should still be opened in Design View.

In the Controls section of the Ribbon, click Hyperlink

1.

In the Insert Hyperlink dialog box, click the Address text box and typehttp://www.functionx.com/rosh

2.

In the Text to display text box, replace the text with School Information

3.

Click OK4.

Move the hyperlink to the form footer section5.

Save the form and close it6.

Other Labels

The Page Number

In a report meant to display various records on its many pages, you may want to display the pagenumber. To assist you with this, Microsoft Access provides a special label. To get it, display thereport in Design View. In the Control section of the Ribbon, click Page Numbers and click thereport. The Page Numbers dialog box would come up:

Use the Page Numbers dialog box to specify what sentence would be used, and where, to displaythe page number. Once you are ready, click OK. The new label would be added to the Page Footersection of the report.

The Date and Time

When displaying a form, if you want to show the current and/or time, Microsoft Access can assistyou with a label. Before creating the label, display the form or report in Design View. To add thelabel, in the Controls section of the Ribbon, click Date and Time and click the form. The Date andTime dialog box would come up:

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht

12 25-Jan-2011 07:12 P

Page 5: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 5/12

Use the dialog box to specify what of the date or the time, including the formats, would display.Once you are ready, click OK. If the form or report did not have the appropriate header and footersection (the Form Header section for the form and the Report Header section for the report), thesection would be created. If the section existed already, it would be used to host the label. Whenthe label is created, by default, it is added to the header section (the Form Header section for theform and the Report Header section for the report). If you do not like those positions, you can

move the label(s). To do this, simply click and drag it(them) to the desired section.

The Text Box

Introduction

A text box is a Windows control used to get or display text for the user’s interaction. At its mostregular use, a text box serves as a place to fill out and provide information. You can also use itonly to display text without allowing the user to change its content.

Like most other controls, the role of a text box is not obvious at first glance; that is why it shouldbe accompanied by a label that defines its purpose. From the user’s standpoint, a text box isnamed after the label closer to it. Such a label is usually on the left or the top side of thecorresponding text box.

There are two main ways you can add a text box to a form or report:

From the Ribbon, you can click the Text Box control and click a section of the form orreport. Unless you have a good alternate reason, most of your text boxes will be placed in theDetail section. Some text boxes used in expressions can be placed in another section. Bydefault, placing a text box on the form or report also adds a corresponding label to i ts left.

If you drag a text-based field from the Field List and drop it on the form or report, the fieldwould place a text box and its corresponding label.

Properties of a Text Box

Like every control on a form or report, the size of a text box is controlled by its Width and Heightproperties. The position of a text box is controlled by its Top and Left properties.

To make a text box read-only, that is, if you do not want the user to enter text in a text box, thereare various alternatives. If you change the Enabled property from Yes to No , the text box wouldhave a gray background and cannot receive focus. If you set the Locked property from No to Yes ,the control would appear with a normal (white) background.

The Special Effects properties of the text box are expanded as compared to those available on alabel. Besides the ability to raise or sink a text box, you can give it a thick, etched, or shadowborder.

After adding a text box to a form or report, you can configure it to receive its data from an existingtable. This can be done after the Record Source of a form or report has been defined. To link a textbox to the object that is the Record Source of a form or report, click the arrow of its Record Sourcecombo box and select the desired field.

Practical Learning: Adding Text Boxes

Re-open the Bethesda Car Rental1 database1.

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht

12 25-Jan-2011 07:12 P

Page 6: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 6/12

In the Navigation Pane, right-click the Assets form and click Design View2.

Double-click the button at the interaction of the rulers. In the Properties window, click RecordSource and select Assets

3.

In the Tools section of the Ribbon, click Add Existing Fields4.

From the Field List, add each field and design the form as you see fi t:

5.

Select each text box and, in the Controls section of the Ribbon, click the arrow of the SpecialEffects button -> Shadowed

6.

Save the form and switch it to Form View

7.

Switch the form back to Design View8.

Pictures

Introduction

A picture is a graphical object that can be used either as the background of a form or report or canbe positioned on top of a database object. Before using such a picture, you should prepare it or atleast have it handy.

In Lesson 8, we saw that, to use a picture as the background of a form or report, in Design View,

you could open the Properties window of the form or report. Then, in the Format tab, you couldclick the Picture field to reveal its ellipsis button, use that button to locate and retrieve thepicture. Once added to the form or report, you could use some other properties to specify how thepicture would be displayed.

Practical Learning: Introducing Pictures

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht

12 25-Jan-2011 07:12 P

Page 7: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 7/12

From the resources that accompany these lessons, open the Altair Realtors1 database1.

On the Ribbon, click Create and, in the Forms section, click Form Design2.

Double-click the button at the intersection of the rulers to access the Properties window3.

Set the Record Source to Properties4.

Save the form as Properties5.

Right-click the form and click Form Header/Footer6.

In the Controls section of the Ribbon, click Label and click under the Form Header bar7.

Type Properties Listing and press Enter8.

In the Tools section of the Ribbon, click Add Existing Fields and design the form as follows (donot try to match the fonts; instead, select the closest fonts you have on your )

9.

Save the form10.

Unbound Objects

Instead of an object whose data is l inked to a field of the database, you can have an object on yourform or report to simply complete the design of the parent object. That is the case for logos or fineprints on forms and reports. On a form or report, an object whose data is not linked to a specificrecord is referred to as unbound.

To add an unbound object, display the form or report in Design View. In the Controls section of the

Ribbon, click the Unbound Object Frame button and click on the form or report. If the ControlWizard button is clicked on the Ribbon, a wizard will help you select the object you want to add toyour form or report.

Practical Learning: Binding an Object

On the Ribbon, make sure that the Use Control Wizards button is highlighted

.

In the Controls section of the Ribbon, click the Unbound Object Frame and click under theForm Footer bar on the right side

1.

On the Microsoft Office Access dialog box, click the Create From File radio button and clickBrowse...

2.

From the resources that accompany these lessons, select the Altai r.bmp file and click OK3.

On the Microsoft Office Access dialog box, click OK4.

Adjust the picture and save the form before previewing it

5.

computer

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht

12 25-Jan-2011 07:12 P

Page 8: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 8/12

Close the form6.

Bound Objects

When reviewing data types, we saw that a bound object is one that is tied to an existing field on atable. To add such a bound object to a form or report, in the Controls section of the Ribbon, you

can click Bound Object Frame and click the desired area of the form or report:

You can then design the size and position of the frame as you see fit:

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht

12 25-Jan-2011 07:12 P

Page 9: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 9/12

Since the object is (supposed to be) bound to a field on the source table (or the source report), themost important piece of information you should provide is the table's field that holds the bounddata. This is specified in the Record Source property. After doing this, the records would show thevalue of the bound object (you should have associated the objects to each record, using the InsertObject dialog box):

A Logo

A logo is a picture that represents or symbolizes a company. You can use such a picture on a formor report to make it cute. In our discussion of unbound pictures, we learned that we could add apicture independent of any record. We also had to decide where to position the picture. If wewanted it to act a as a logo, we had to put it in the form header section. To formally add a logo toa form a report, Microsoft Access can assist you.

Before using a logo in your database, you must create it, design it, and save it as a picture file. Toadd the logo, display the form or report in Design View. In the Controls section of the Ribbon, click

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht

12 25-Jan-2011 07:12 P

Page 10: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 10/12

Logo

Lo

. This would open the Insert Logo dialog box where you can select a picture.

Practical Learning: Adding a Logo

Re-open the Red Oak High School database1.

In the Navigation Pane, under Students: Table, right-click the Students form and click DesignView

2.

In the Controls section of the Ribbon, click Logo

Lo

3.

From the Insert Picture dialog box, locate the resources that accompany these lessons andselect the rosh.png picture

4.

Click OK5.

Move the logo to the left and the title to the center of the form footer section of the form:

6.

Save the form7.

The Line and the Rectangle

The Line

To enhance the appearance of sections or controls on forms and reports, Microsoft Access providesa line object. You can use it to trace horizontal, vertical, or diagonal lines of various preset widths.The use, position, and orientation of a line only depend on your goal.

To add a line, display the form or report in Design View. In the Controls section of the Ribbon, click

the Line object and click the form or report.

Practical Learning: Adding Lines

The Students form of the Red Oak High School database should still be opened in Design View.

In the Controls section of the Ribbon, click Line and drag a horizontal line below the title inthe form header section

1.

Again, in the Controls section of the Ribbon, click Line and drag a horizontal line below thefirst line

2.

While the new line is still selected, in the Controls section of the Ribbon, click the arrow of the

lick the Line Thickness button and select 2 pt

3.

Move both line to the l eft to touch the left border

4.

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht

f 12 25-Jan-2011 07:12 P

Page 11: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 11/12

Save the form5.

The Rectangle

To enhance the appearance of sections or controls on forms and reports, Microsoft Access providesa rectangle object. It is not a control (for example, it does not "own" of fire events; in other words,it does not programmatically communicate with the operating system, it does not store or receivedata nor does it provide data). It is a graphical object primarily intended for aesthetic purposes.There is no formal directive on how to use the rectangle.

There are various reasons you would use a rectangle on a form or a report. You can use it to"hold" other controls. For example, if you want to isolate a group of controls, you can include theminside of a rectangle. To add a rectangle, display the form or report in Design View. In the Controls

section of the Ribbon, click the Rectangle object and click the form or report. To exploit theaesthetic role of a rectangle, you can change such as aspects as the back color, the borders, or thespecial effects, etc.

Practical Learning: Adding a Rectangle

The Students form of the Red Oak High School database should still be opened in Design View.

In the Controls section of the Ribbon, click Rectangle and click the Detail section of theform

1.

While the rectangle is still selected, in the Font section of the Ribbon, click the arrow of theFill/Back Color button and select Background (Access Theme Colors: 5th column - 1st row)

2.

In the Controls section of the Ribbon, click the arrow of the Special Effects button and selectSpecial Effects: Shadowed

3.

Access the Properties window of the form and set its Record Selectors property to No 4.

Save the form5.

Lessons Summary

MCAS: Using Microsoft Office Access 2007 Topics

C7 Modify the design of reports and forms

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht

f 12 25-Jan-2011 07:12 P

Page 12: Lesson 11_ Data Controls

8/6/2019 Lesson 11_ Data Controls

http://slidepdf.com/reader/full/lesson-11-data-controls 12/12

Previous Copyright © 2008-2010 FunctionX, Inc. Next

Oracle Software Let us assist with your Oracle licensing requirements www.velocity3.co.za

Golf Tutorials Blast Straight Long Gorgeous Drives In 72hrs or Less Guaranteed! DocsGolfTips.com/Golf_Tutorials

CATIA South Africa SA No#1 Reseller of CATIA CAD/CAM Sale/Rental/Training 011 786 3516 www.CATIA.co.za

Indigo Vision For all software development and integration needs indigovision.co.za

rosoft Access - Lesson 11: Data Controls http://www.functionx.com/access2007/Lesson11.ht