Reports - UF Health Information Technology Training

advertisement
Microsoft Access 2003
Introduction to
Forms & Reports
Email: training@health.ufl.edu
Web Page: http://training.health.ufl.edu
Microsoft Access 2003: Intro to Forms and Reports
2.0 hours
This workshop requires completion of "Access: Basics"; "Access: Tables &
Relationships" recommended. Topics include using AutoForm, form wizards,
AutoReports, report wizards, and creating simple forms and reports in a design view.
Worksheets:
Forms .................................................................................................................................. 1
New Forms .......................................................................................................................... 2
AutoForm: Columnar ...................................................................................................... 3
AutoForm: Tabular ......................................................................................................... 3
AutoForm: Datasheet ...................................................................................................... 3
AutoForm: Pivot Table ................................................................................................... 4
AutoForm: Pivot Chart ................................................................................................... 4
Reports ................................................................................................................................ 5
New Reports........................................................................................................................ 6
AutoReport: Columnar.................................................................................................... 7
AutoReport: Tabular ....................................................................................................... 7
Designing Forms and Reports ............................................................................................. 8
Labels and Text Boxes .................................................................................................... 8
Moving with the Mouse .............................................................................................. 8
Font Size ..................................................................................................................... 8
Field List ......................................................................................................................... 9
Tool Box ......................................................................................................................... 9
Working in the Design View .......................................................................................... 9
Moving with the Keyboard ......................................................................................... 9
Resizing....................................................................................................................... 9
Making Multiple Selections ........................................................................................ 9
Notes about Deleting................................................................................................... 9
Special Formatting Tools .............................................................................................. 10
Size............................................................................................................................ 10
Aligning Objects ....................................................................................................... 10
Horizontal and Vertical Spacing ............................................................................... 10
Sorting and Grouping ................................................................................................ 10
Toolbox ............................................................................................................................. 11
Pandora Rose Cowart
Training Specialist
Information Technology Center
Health Science Center
PO Box 100152
Gainesville, FL 32610-0152
352-273-5051
prcowart@ufl.edu
http://training.health.ufl.edu
Page 1
Forms
Access has an AutoForm button (
) to create an instant forms. From the tables or queries tab,
highlight the item and click on the AutoForm button. If the form icon with the lightening bolt is
not in the New Object button, then click the dropdown arrow to choose AutoForm.
This is the data I will use through out this worksheet:
This is a sample of an AutoForm created with the New Object button:
Notice it gives all the information from
our table, in a neat column, one record
at a time. There are several similarities
between the form and the table. Both
have a record selector ( ) and
navigation buttons along the bottom
(
).
You can edit this form using the Design
View Button (
), or by choosing
Design View, from the View menu.
Updated 02/14/09
Page 2
This is the design view of the form on the previous page. More on the design view later.
New Forms
To create a new form, click the New
button
on the database window,
on the Forms tab you will see a
window like the one shown here on the
left.
Design View will allow you to build a
form from scratch. If you want it to be
a menu form, then you can leave the
“Choose the table or query…” box
blank.
The Form Wizard, Chart Wizard,
and Pivot Table Wizard will walk
you through a wizard to help you set
up the form.
The AutoForm options will create an instant form, like the New Object button does, but it will
use the formatting that the last wizard used. These are the formats available through the wizard:
Blends
Blueprint
Expedition
Industrial
International
Rice Paper
Sand Stone
Standard
Stone
Sumi Painting
Updated 02/14/09
Page 3
AutoForm: Columnar
The AutoForm button that
can be used from the Tables
or Queries tab creates a
columnar form with no
formatting. Notice that for
this Columnar Form the
fields are grown to the size of
the max data allowed.
AutoForm: Tabular
AutoForm: Datasheet
The datasheet form looks just like the table. This is ideal for building SubForms.
Updated 02/14/09
Page 4
AutoForm: Pivot Table
Beginning in Microsoft Access XP (2002) there is an AutoForm for Pivot Tables and Pivot
Charts. You have always been able to use Pivot Tables in Access, but previous versions have
placed you in a Microsoft Excel Applet, and inserted the pivot table. The newer versions have
their own built in pivot table options. I still recommend copying your data into excel, or using
the cross tab queries, as these tools seem cumbersome to work with, but here are some samples
of the number of patients in each city.
AutoForm: Pivot Chart
Updated 02/14/09
Page 5
Reports
Reports are specifically designed to display and print data. As with Forms, Access has an
AutoNew button to create an instant report (
). From the tables or queries tab,
highlight the item and click on the AutoReport button. These often make sloppy, but
instant Reports. If the green notebook is not in the AutoNew button, then click the
dropdown arrow to choose the AutoReport.
Using the same data as with the Forms section of this documentation, this is a sample of
an Auto Report:
This report will show all the
information from our table, but that
is all it does. The AutoReport
button takes everything in your
table or query and throws it on the
report.
You can edit this report using the
Design View Button (
), or by
choosing Design View, from the
View menu.
Updated 02/14/09
Page 6
New Reports
To create a new report, click the New button
on the database window, on the
Reports tab you will see a window like the one shown here.
Creating a report in Design View will allow you to build a report from scratch. Be sure to
choose a table or query at the bottom. The Report Wizard, Chart Wizard, and Label
Wizard will walk you through to help you set up a report.
The AutoReport options will create an instant form, like the New Object button does,
but it will use the formatting that the last wizard used. These are the formats available:
Updated 02/14/09
Bold
Casual
Compact
Corporate
Formal
Soft Gray
Page 7
AutoReport: Columnar
The AutoReport button that can be used
from the Tables or Queries tab creates a
columnar report with no formatting.
Notice that for this Columnar Report the
fields are grown to the size of the max
data allowed and they all have boxes
around the data. This AutoReport has
also put a Report Header “Patients” and a
Page Footer on this report.
AutoReport: Tabular
As with the AutoReport:
Columnar, this option
puts a report header,
page header and footer
on the report. To obtain
this view, it also puts the
labels for each column in
the page header.
Updated 02/14/09
Page 8
Designing Forms and Reports
There are many similarities between the basic design view of Forms and Reports.
Form View
Print Preview (Report)
Design View of Form
Design View of Report
Above is the label and text box for the Last name of our patient in design view. A label appears
the same in both design and data view. A text box shows the field name it’s pulling from in the
design view and will display the actual data in the form or print preview. Whether you are in the
design view of a Form or a Report, when you select a Text box, it will look like this:
Labels and Text Boxes
Moving with the Mouse
When you place your mouse anywhere on the edge of the text box, between the sizing handles,
your mouse arrow will turn into a full hand ( ). This hand also appears when you click and hold
on an unselected object. When you click and drag the mouse while the pointer shows the full
hand, both the label and the text box will move.
The upper left corner of the label and the text box both show a square larger than the sizing
handles, this is to identify the link between the text box and its label. When you place the mouse
in this large square, your pointer will turn into a hand pointing only one finger ( ). This will
allow you to move the item independently of its partner text/label box. To separate a label from
its text box, you can cut and paste the label.
Font Size
When you change the font size, Access will not resize the box. If you place your mouse over one
of the sizing handles and double click, it will AutoFit the selected box to the correct height. If it
is a label it will attempt to adjust to the width.
Updated 02/14/09
Page 9
Field List
The Field List ( ) should open automatically when you are in the design view of your form or
report, if it does not you can open it from the view menu, or by using its button on the toolbar.
The Field List displays a list of all the possible fields from the data source (the table or query). If
this list is empty, or the option to view the list is unavailable, it means you do not have a data
source. You can set one through the properties of the Form. To place the fields on the form,
select them from the field list and drag the field names to the form or report.
Tool Box
The Toolbox ( ) should open automatically when you are in the design view of your form or
report, if it does not you can open it from the view menu, or by using its button on the toolbar.
Click the tool you want, and then click the location on the form or report where you want the
object to appear. Some items such as the command buttons and combo boxes run with wizards. If
you want to turn the wizard feature on or off use the button ( ) located at the top of the toolbox.
For more details on the specific tools in the toolbox, see the last two pages of this worksheet.
Working in the Design View
Moving with the Keyboard
Beginning in Office XP you can move items one grid point at a time by using the arrows on the
keyboard. In every version of Access, you can move an object a quarter of a grid point by
pressing Ctrl in conjunction with the arrow keys.
Resizing
When you place your mouse on the any of the selected objects sizing handles you will get a
double arrow (
). Click and drag the mouse and the box will resize the selected items.
Making Multiple Selections
There are several ways to make a multiple selection in the design view.
1. Shift Key: To select more than one item in the design view, click on the first item and
then hold down the shift key on the keyboard and click on each subsequent item you wish
to select. If you mean to include the labels, don’t forget to click on them as well.
2. Items in a Line: When the objects you would like to select are all in a row or column,
you can click in the ruler and Access will select everything in the path of that selection.
3. Selection Box: If you click in a part of the grid that is unoccupied by any objects and
drag the mouse over the objects you would like to select, you will see a selection box
being drawn. Any items that the selection box touches will be selected, be careful with
this, especially in reports where there are so many lines.
No matter how the object is selected, the Shift key can also be used to unselect a selected object.
(Shift-click on the selected object to unselect.)
Notes about Deleting
If you delete the text box the label will be deleted as well, however if you delete the label the text
box will remain on the screen. If you delete a button, Access will not delete the VBA code used
to support that button. This is addressed in the Access Forms handout.
Updated 02/14/09
Page 10
Special Formatting Tools
There are several formatting tools to help organize the controls on your forms and reports.
Size
Select the objects you want to change. From the Format menu, or the
right-click menu, choose Size.
The To Fit option is the same as double clicking on the sizing handles, it
will fit all the selected objects to their own best fit.
Tallest and Shortest are the vertical sizes, Widest and Narrowest are the
horizontal sizings.
Aligning Objects
Select the objects you want to adjust. From the Format menu, or the right-click
menu, choose Align. This will align the controls to each other based on the
option you choose.
Unlike the other Microsoft Office products, Access’s align feature has no
Center or Middle and it will not overlap controls. If two controls are in a direct
line, they will be placed touching each other along the adjoining edge.
Horizontal and Vertical Spacing
You can adjust the spacing between the objects on your
form or report by using the spacing options in the
Format menu.
Keep in mind that the spacing is relative to the objects
that are selected, not to the form or report itself
Sorting and Grouping
Reports have one tool that Forms do not and that is the Sorting and Grouping option found
under the View menu, or through the button ( ). This tool will allow you to sort and group your
data. Choose a Field/Expression to sort by and then turn on the Group Header to Group by that
Field/Expression. This will be discussed further in the full reports workshop.
Updated 02/14/09
Page 11
Buttons of the Toolbox
When you are creating/designing a form or report you will see a toolbox such as
the one shown on the left. If the toolbox is not showing while you are in design
view, look for this button:
on the toolbar to turn it back on, or choose Toolbox
from the View menu.
By default the arrow (Select Objects) and the magic wand (Control Wizards) are
turned on, notice how they look pushed in on the toolbox. Some tools such as the
command buttons and combo boxes are only useful for form, but are available
with forms and reports.
Select Objects
Control Wizards
Use to select an object, a section, a
form, or a report. When you select a
control you use it once and it turns
off. If you double-click the tool will
turn it on and keep it on, then click
back on this button to turn return to
the select tool.
Turns control wizards on or off.
When you try to create something
such as an option group, a combo box
or a command button the wizard will
automatically be launched when the
object is placed on the form or report.
If the wizard does not activate make
sure this button it turned on.
Label
Text Box
Labels display the same information
in the design view and the data view.
They are most often used for titles,
captions, or instructions.
Text boxes are different in data view
and in design view. Data can come
from the data source or calculation.
Option Group
Toggle Button
Use to create a section of related
check boxes or option buttons.
Use as a stand-alone control bound to
a Yes/No field. If you want more
than one toggle button you should
create an option group.
Option Button
Check Box
Use as a stand-alone control bound to
a Yes/No field. If you want more
than one option button you should
create an option group.
Use as a stand-alone control bound to
a Yes/No field. If you want more
than one check box to correspond to
the same field you should create an
option group.
Updated 02/14/09
Page 12
Combo Box
List Box
Create a lookup via a drop down
menu. You can type in the text box or
select an entry in the drop down box
to add a value to a bound field.
Create a lookup via a list of options.
The list box will display all the
possible choices and highlight only
the chosen option.
Command Button
Image
Create a button to perform simple
tasks such as record navigation and
form and report operations.
Use for displaying a static picture on
a form or report, such as a logo.
Unbound Object Frame
Bound Object Frame
Use to display an unbound OLE
object, such as an Excel spreadsheet.
The object will remain constant on
each page or record.
Use to display OLE objects saved in a
field in the record source. A different
object will be displayed for each
record.
Page Break
Tab Control
Used to create a new page on
printouts of a form or report. Be
careful not to leave any extra space
below a page break within its section
or you may end up with an extra page
at the end of the whole report/form.
Use to create a tabbed form with
several pages. Each page has its own
tab order.
SubForm/SubReport
Line
Use to create or insert a form or
report into the current form or report
to see data from another data source.
For example the medications for each
patient.
Draws a line. Used to emphasize
related information.
Set Height
property to zero for a straight line.
Rectangle
More Controls
Draws a rectangle. Used mostly for
visual clarity of groups.
Use to access a menu that displays
other controls you can utilize to
create your form.
Updated 02/14/09
Download