Top Banner
Building a User Interface with Forms
32
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 005.form

Building a User Interface with Forms

Page 2: 005.form

Creating Simple Forms

Creates a readymade form based on a table orquery:

− In the navigation pane, select the table orquery use to generate the form.

− Choose Create ➝ Forms ➝ Form.

Page 3: 005.form

Using Forms

Finding and Editing a Record

Adding a Record

Deleting a Record

Printing Records

Sorting and Filtering in a Form

− Quick filter

− Filter by selection

− Filter by condition

− Advanced filters

Page 4: 005.form

More Useful Form Properties

The Property Sheet to change the view of yourform, letting an ordinary form show multipleitems or a split view.

However, the Property Sheet is packed withmany more settings.

(reference to Table 12-2, Page 396)

Page 5: 005.form

The Form Wizard

The Form wizard asks you a series of questionsand then builds a form to match.

− Choose Create ➝ Forms ➝ Form Wizard.

− From the drop-down list, choose the table youwant to use.

− Add the fields you want to include, click Next.

− Choosea layout option for your form.

Page 6: 005.form

The Form Wizard

Layout options include:

− Columnar similar to clicking Create ➝ Forms➝ Form on the ribbon.

− Tabular similar to clicking Create ➝ Forms ➝More Forms ➝ Multiple Items in the ribbon.

− Datasheet creates a datasheet form. It’ssimilar to selecting Create ➝ Forms ➝ MoreForms ➝ Datasheet in the ribbon.

Page 7: 005.form

Designing Advanced Forms

Customizing Forms in Design View:

− Create a form in Layout view: Choose CreateForms Blank Form.

− Drag the fields from the Field List pane intoform.

− Create a form in Design view. Choose Create Forms Form Design. Start with a blankform in the design window.

− Drag fields from the Field List pane into form.

Page 8: 005.form

Form Sections

Newly created forms start with only onesection: the Details section, which defines thecontent for each record.

Page 9: 005.form

Form Sections

To add a title or logo at the top of form, or somesort of summary information or message at thebottom, must include a header and footersection.

To add these elements to form, right-clickanywhere on the form’s surface, and thenchoose Page Header/Footer.

Page 10: 005.form

Adding Controls to Your Form

To add a control, follow these steps:

− Head to the ribbon’s Form Design ToolsDesignControls section.

− Optionally, switch on the Use Control Wizardsbutton.

− Click the icon for the control you want.

− To place your control on the form, drag themouse cursor to draw the control on the form.

− If control has a Control wizard and useControl Wizards, the wizard appears now.

Page 11: 005.form

Adding Controls to Your Form

− If you’re adding a label, supply some text forthe control.

− Change the appropriate settings in theProperty Sheet.

− Give control a better name by setting theName property.

− Format your control.

Form controls (reference Table 13-1. Page 407)

Page 12: 005.form

Arranging Controls on Form

Working with controls in Design view:

− Create a control: Select the control youwant, and then draw it in the right place.

− Move a control: Just click and drag it. You canalso move several controls at Once.

− Resize a control: Drag the edges of therectangle that surrounds it.

− Modify a control: Select control and setproperty in the Property Sheet.

− Delete a control: Select it press Delete

Page 13: 005.form

Arranging Controls on Form

Aligning controls:

− Select the control, right-click

− Choose an option in the Align submenu

− Or select Arrange Align

Page 14: 005.form

Arranging Controls on Form

Sizing controls:

− Select the controls, right-click theselection, choose an option from the Sizemenu.

− Use To Widest to make all the controls as wideas the widest one of the bunch.

Spacing controls:

− To modify the space appears between thecontrols:

Page 15: 005.form

Arranging Controls on Form

− Select all the controls Form Design Tools |Arrange ➝ Sizing & Ordering ➝Size /Spacemenu.

− Select the commands to adjust the spacingbetween controls:

Equal Horizontal.

Equal Vertical.

Increase Horizontal and Increase Vertical.

Decrease Horizontal and Decrease Vertical.

Page 16: 005.form

Anchoring: Automatically Resizing Controls

Normally, the controls have a fixed, unchangingsize. Fixed size controls make for easydesign, but they’re inflexible.

Anchoring lets you create controls that cangrow to fill extra space when the Accesswindow is resized.

Page 17: 005.form

Anchoring: Automatically Resizing Controls

Making controls as wide as the form

− In Design view, shrink the width of the Detailssection so it’s just wide enough to fit controls.

− Choose the controls that you want to expandalong with the window’s size.

− Choose Form Design Tools Arrange

Position Anchoring Stretch Across Top.

Page 18: 005.form

Taking Control of Controls

Locking Down Fields: Every bound controlprovides the following two properties that youcan use to control editing by using the PropertySheet in Design view.

− Locked determines whether you can makechanges in a field.

− Enabled lets you deactivate a controlaltogether.

Page 19: 005.form

Taking Control of Controls

Prevent Errors with Validation:

− Validation Rule sets an expression that thevalue must meet to be considered valid.

− Validation Text.

− Input Mask.

− Default Value

Page 20: 005.form

Performing Calculations with Expressions

To create an expression on form:

− Add a text box control to your form

− In the Property Sheet, choose the Data tab.Place expression in the Control Source setting.

− Optionally, set Enabled to No to hammer homethe point that this value can’t be edited.

− Optionally, apply formatting.

Page 21: 005.form

Organizing with Tab Controls

Tab control is used:

− Present large amounts of content in a limitedspace. Organize this content into separatepages. At a time, can see only one page.

− In forms that are primarily designed forediting or reviewing data, data can besubdivided into logical groups, and editingtasks often involve just one group.

Page 22: 005.form

Organizing with Tab Controls

To use a tab control, follow these steps:

In the ribbon’s Form Design Tools DesignControls section , click the Tab Control.

Draw the tab control onto form

Every new tab control starts with two pages.

− To create a new page, right-click any tab andchoose Insert Page.

− To remove an existing page, right-click it andchoose Delete Page.

Place controls on the different pages.

Page 23: 005.form

Navigating with Lists

There are two list controls in Access forms: thelist box and the combo box.

There are two ways to use list controls:

− Use to edit a field. Access automaticallycreates a combo box control when there’s alookup defined for the field

− Use to navigate to the record, the list showsthe field value for every record in the table.When choose one of the values, Access jumpsto the corresponding record.

Page 24: 005.form

Navigating with Lists

Create List control:

− Make sure the Control Wizard feature isturned on.

− In Form Design Tools Design Controlssection, click List Box or Combo Box.

− Draw the control on the form.

− Choose “Find a record on my form”Next.

− Choose the field you want to use for thelookup Next.

− Enter a caption for list Finish

Page 25: 005.form

Command Buttons

Command buttons let you trigger just about anyaction, like opening a new form, printing areport…

Crate Button by using wizard:

− In the ribbon’s Form Design Tools Design Controls section, click the Button.

− Draw the button into form.

Page 26: 005.form

Command Buttons

− Choose one of the actions:

Record Navigation

Record Operations

Form Operations

Report Operations

Application

Miscellaneous

− Click Next

− Enter some text and choose a picture Next

− Supply a name for the button Finish

Page 27: 005.form

The Sub form Control

The sub form control shows linked records

Three properties determine what the sub formcontrol shows:

− The Source Object property identifies theobject in the database that has the relatedrecords.

− Link Master Fields: is the field in the form.

− Link Child Fields: is the field in the sourceobject.

Page 28: 005.form

Navigation Forms

Creating a Single-Level Navigation Form:

− To create navigation form, pick one of the topthree options from the Create ➝ Forms ➝Navigation menu.

− To add a navigation button for one offorms, click the form in navigation pane, anddrag it into the navigation control.

− If want to change the navigation buttoncaption, double-click the caption and type thenew name.

Page 29: 005.form

Navigation Forms

Creating a Two-Level Navigation Form:

− To create navigation form, pick one of thebottom three options from the Create ➝Forms ➝ Navigation menu.

Page 30: 005.form

Navigation Forms

− Add a heading for your top-level menu by click“[Add New]” and type in a new caption.

− To add the submenu for this heading, drag aform from the navigation pane into thesubmenu.

Page 31: 005.form

Linking to Related Data

Showing Linked Records in Separate Forms: Byadding a button to form that pops open anotherform with the linked records

− Open the parent form in Design view.

− Click the Button icon, and draw the buttononto form.

− Choose the Form Operations OpenForm, Next.

− Choose the child form that has the relatedrecords , Next.

Page 32: 005.form

Linking to Related Data

− Choose “Open the form and find specific data todisplay”Next.

− In the list on the left, choose the uniqueidentifying field from the first table.

− In the list on the right, choose the matchingfield from the second table.

− Click the two-way arrow button Next

− Finish.