Transcript Chapter 3

1
Chapter 3
Reviewing Forms,
Reports, and Data
Access Pages
3
Chapter Objectives
• Design easy-to-use forms and data access pages
that facilitate the entry of valid data
• Bind forms, reports, and data access pages to
tables and queries
• Create expressions that display the result of
calculations
• Create groups within the database window that
contain related forms, reports, and data access
pages
3
Reviewing Forms, Reports,
and Data Access Pages
• In addition to table and query datasheets,
Access offers three ways to display data:
forms, reports and data access pages
• These objects contain:
 Sections
 For example, header and detail sections in forms, page
and group headers in reports, and captions and headers in
pages
 Controls
 For example, text boxes and check boxes
3
Reviewing Forms, Reports,
and Data Access Pages
• Forms, reports, data access pages, and their
corresponding sections and controls have
properties
 Property sheet
 A window in which you can modify the properties
of an object
 Used to specify the format of an object
 Used to specify valid input
3
Forms, Controls, and
Properties
• Professionally styled Access applications
have users enter and view data through
forms (or pages on the Web)
• Forms
 Can be customized to mirror other documents
in the work environment
 Help enforce data integrity by restricting the
data that the user may enter
3
Components of a Form
• A form control
 Refers to any object that is placed on the form
• Form Header
 Contains column headings for a form
• Form Footer
 Contains controls that summarizes values in Detail section
• Detail section
 Values displayed change depending upon the record that is
currently being viewed
3
Components of a Form
Figure 3-1 Design view of frmProspects
3
Unbound and Bound Forms
• Bound form
 Form that is tied to, or associated with, either a table or
query
• Record source
 Table or query with which the form is associated-that is,
the source of the data
• RecordSource property
 Listed in the Data tab of the form’s property sheet
 May contain the name of the table, the name of a query,
or an SQL statement
3
Unbound and Bound Forms
• Unbound form
 Form that is not tied to any table or query
• Splashscreen
 Displays one or more brief messages to the user that
automatically appear and disappear
• Switchboard
 Do not display data, but rather contain command
buttons that open reports or other forms
3
Controls
• ControlSource property
 Located in the Data tab of the control’s
property sheet
• Unbound controls
 Controls that do not have a value for their
control source property
3
Properties
• A property sheet contains five tabs
• Properties in:
 Data tab
 Specify the record or control source
 Format tab
 Control the aesthetics of the object
 Event tab
 Used to link an object to a VBA procedure or macro
3
Properties
• A property sheet contains five tabs (cont.)
• Other tab
 Contains miscellaneous properties such as the
name of an object
 Name property
 Used in VBA procedures and macros to refer to object
• All tab
 Displays all of the properties specified
3
Form Style
• Tips that facilitate good form style:
 Use a consistent color and formatting scheme
 Use a consistent button, menu, and toolbar
scheme across related forms
 Restrict the amount of text and pictures on a
form to a volume that a use can easily
comprehend
 Use a soft coloring scheme that is easy to look
at for long periods of time
3
Form Style
• Tips that facilitate good form style (cont.):
 Build an application that helps the user
remember valid data entries
 Test the user interface for understandability of
the graphics and for cultural sensitivity
 Determine the type of monitors that will be
used in conjunction with your application
3
Form Style
• Tips that facilitate good form style (cont.):
 Use shortcut keys or access keys to allow the
selection of menus, toolbars, and command
buttons through keystrokes
 A shortcut key is a keystroke that executes a menu
item or command immediately
 An access key moves the focus to an item in the
menu
3
Working with Forms
• You can place a background image on a form
by specifying the path to a picture in a form’s
Picture property
• Background colors of controls and from
sections are set through the BackColor
property
• The text color of a control is set using a
control’s ForeColor property
3
Working with Forms
Table 3-1
Common form
design tasks
3
Working with Forms
• To remove the navigation buttons that
appear on the bottom of the form:
 Select No in the form’s NavigationButtons
properties
• To remove the record selector that appears
on the side of the form:
 Select No in the form’s RecordSelector
properties
3
Working with Forms
Table 3-2
Form design
wizards
3
Working with Forms
Table 3-2 Form design wizards (continued)
3
Controls That Organize: Tab
Controls and Subforms
• When you use a Tab Control control instance
to organize controls on a form, the user can
click a tab to display the controls that are
located within the particular tab
• Subform control instance
 Allows a form (referred o as the main form) to
display the contents of another record source
3
Controls That Organize: Tab
Controls and Subforms
• The property sheet of the subform identifies
the fields that link the main form (Link
Master Fields property) to the subform
(Link Child Fields property)
• Source Object property
 Contains the name of the form displayed by the
subform
3
Controls That Display and
Update Data
• When you modify a form or create an unbound
form, you can place controls on a form by:
 Clicking a control on the toolbox and then dragging
the mouse on the form to indicate the location and size
of the control
 If the toolbox is not displayed, click the Toolbox
button in the toolbar
• Field list
 Contains a list of fields in a form’s record source
3
Controls That Display and
Update Data
Table 3-3
Data entry
and display
controls in
Access
3
Controls That Display and
Update Data
• Calculated control
 A control with an expression
• RowSource property
 Contains an SQL statement or the name of a
table or query that contains the values to be
displayed in the combo box
 May return more than one field
3
Controls That Display and
Update Data
• BoundColumn property
 Identifies the field that will become the value of
the combo box after the user selects an item
 Contains an integer that corresponds to the
order of the column
• ColumnWidths property
 Indicates the size of the fields to be displayed
within the combo box
 Occasionally, a width is set equal to zero
3
ActiveX Controls
• ActiveX controls
 Similar to Access controls, except they have
been developed for other applications
• Clicking More Controls in the toolbox
 Displays a list of ActiveX controls
3
ActiveX Controls
• Spin button
 Allows a user to click on an arrow to increase
or decrease the value of a field
 Amount of the increase is set up in the control’s
SmallChange property
 Contains the Maximum and Minimum
properties that restrict the valid values that can
be entered
3
Option Groups
• Option group
 Displays a group frame containing toggle
buttons, option buttons, or check boxes
 Ensures that the user will select a valid value
3
Working with Property Sheets
to Enforce Data Validity
• To allow users to change the data on a form,
you must set the form’s AllowEdits property
to Yes
 Set AllowDeletions to Yes to allow users to
delete records
 Set AllowAdditions to Yes to allow users to
add new records
3
Working with Property Sheets
to Enforce Data Validity
• To change the value displayed through a
control, set the Locked property to No and the
Enabled property to Yes
• A way to distinguish controls is to change the
BackStyle property to transparent
3
Working with Property Sheets
to Enforce Data Validity
• Input Mask, Validation Rule, Validation
Text, and Default Value are important
properties in the Data tab of a control
 Similar to the field properties with the same
names found in the table’s Design view
 Access automatically uses them when these
values are set as field properties within the
control’s ControlSource property
3
Creating Conditional Formats
• Conditional Formatting dialog box
 Opened from the Format menu
 Specifies the conditional formats
• Field Value Is condition
 Sets the format when the value of the
corresponding control meets certain conditions
3
Creating Conditional Formats
• Expression Is condition
 Allows you to change the properties of one control
while testing the values of different controls
• Field Has Focus condition
 Allows you to change properties when the user places
the cursor in the control
• ForeColor, BackColor, and Enabled properties
 Can be changed when the condition is True
3
Form Design Considerations
That Influence Maintenance
• Organization and standards are half the
battle when creating easy-to-maintain
systems
• One standard that facilitates programming
and maintenance is consistent use of object
naming conventions
• These naming conventions require tags to
appear in front of all object names
3
Creating Reports
• Reports
 Provide access to data in tables and queries
 Read-only access
 Means that the report cannot modify data in its
record source
 Normally, reports are printed on paper
3
Report Sections
• Controls in the Report Header appear once
at the beginning of the report
• Controls in the Report Footer appear at the
end of the report
• Page Headers and Page Footers display
controls at the beginning and end of the page,
respectively
3
Report Sections
• Report group
 Set of records that share a common value for a
particular field
• Controls in a Group Header appear at the
beginning of a report group
• Controls in the Group Footer appear at the
end of a report group
3
Report Sections
Figure 3-10
rptEmployer
3
Report Sections
Figure 3-11
rptEmployer
in Design
View
3
Report Wizards
• Simplest way to create a report is through
report wizards
 Similar to form wizards
 Available from the shortcut menu prompts for
the tables and queries for the record source
3
Data Access Pages
• Data access pages
 Special Web interface supported by Access
 Stored as an HTML file
• HTML files do not physically reside inside an
Access mdb file
 Icons within the Page tab of the Database window point
to the HTML file
 The HTML file contains a reference back to the
database
3
Creating a Data Access Page
• Header sections
 Display records from a table or query
• RecordSource property
 Identifies table or query used to supply data to section
• Bound HTML control
 Similar to a locked text box, but is preferred because it
displays data more efficiently
• Controls that display or update data have a
ControlSource property
3
Creating a Data Access Page
• You can add bound controls to a section by
dragging a field from the Field List window
Figure 3-13
Field list window
of a data access
page
3
Creating a Data Access Page
Figure 3-14
Page view of
pagCitizenships
3
Creating a Data Access Page
Figure 3-15
Design view of
pagCitizenship
3
Creating a Data Access Page
• Footer
 Displayed at the end of a group
• Caption
 Contains labels that appear prior to the data in
the Header
• Navigation section
 Contains controls that allow the user to
navigate through various displayed records
3
Creating a Data Access Page
• Sorting and Grouping window
 Specifies whether these sections are created
• Data Page Size text box
 Located in the Sorting and Grouping window
 Indicates the number of records that should be
displayed at one time
3
Creating a Data Access Page
Figure 3-16
Sorting and
Grouping
window
3
Creating a Data Access Page
• To create a new group, click the control to
promote it and then:
 Click Promote or
 Click Group by Table in the toolbar
 Creates a section that will contain all of the fields in
the table
• Clicking Demote removes a section
3
Chapter Summary
• Forms, reports, and data access pages are the
system from an end user’s point of view
• Forms
 Principal interface of an application
 Display data and allow the user to update data
 Should be designed to help the user enter valid data
• Reports support printed reports
• Data access pages support interaction through the
Web
3
Chapter Summary
• Most forms, reports, and data access pages
are bound to a table or query through the
RecordSource property
• Wizards are frequently used to create an
initial version of a form, report, and data
access page
• Forms, reports, and data access pages
should obey proper design characteristics