Professional Documents
Culture Documents
Access Workshop 2
Access Workshop 2
Problem/Opportunity
Hammer Wines Pty Ltd needs an easy to maintain database. The database should
easily allow various staff members to input and edit data. Hammer Wines Pty Ltd
also want to start extracting information from their database such as “Which
customers own/operate which venues?” This information could be used by the
salesperson to gauge the marketing success of the increased sales as a result of beer
being available from a tap.
Activity 1
Forms
Forms are an easy way to enter and display the data from the tables. They make it
easy to maintain your data, i.e., entering, editing or deleting records. You type the
data into the form, and Access stores it in the underlying table. This is why the more
work you put into the design of the underlying tables the easier it will be to set up
the forms. The same with displaying a record – Access picks it up from the underlying
table and displays it for you in the form. So before you begin, double check your
tables to ensure the data is accurate and you have thought of every way you can to
reduce input error.
Usually forms display only one record on the screen at a time. This makes them
easier to use than viewing your table directly, where many records may be on the
screen at a time.
Creating a Form
Access is quite intuitive when it comes to creating forms. As long as you have
selected the table from the Navigation Pane, it will create a form for you.
Select the Customers table from the Navigation Pane.
Select the Create toolbar, Forms section, click on the Form button.
A form should appear automatically. The form has all the fields of the Customers and
all the fields of the Venue tables. The layout could be improved. The areas to insert
data are too large and our contact details do not stand out. See Figure 1 for
changes. It is time to redesign the form.
Data View
You’ll see that there are 2 sets of navigation buttons.
You can navigate through the Customers or you can navigate through the
Venues for a particular Customer.
You’ll see that our drop-down list for VenueID in the venue table is in
operation.
Designing A Form
Click the View icon on the Home tab (in the top left hand
corner of your screen). The layout view enables you to change the
width of the fields and the order of the fields, but nothing really
creative.
OR
Click on the View icon in the bottom right hand corner of your screen
.
Select the Layout view, where we can change the width of the fields.
The Customer ID should already be selected with an orange border.
Move the mouse to the right hand edge of the field to get a double
headed arrow, click and drag to a more appropriate size. Remember
some data may be longer. Note this will change all the other field
sizes as well.
Select Design View.
.
Figure 2 – Design view of a form
General
Note the grid and the rulers to help you align the information.
Note the header, detail and footer sections.
Note the Controls section of the Forms Design Tools toolbar is now on display
in the Ribbon area, this displays all the tools that are at your disposal to help
you to improve/alter the design.
Controls
The objects on a form are called controls. There are three types of controls:
Type of Control Explanation
Bound A bound control is ‘bound’ to the underlying table and is used to
enter or change data in the table (e.g., the white box called
‘CName’ is a bound control. This control will display the
Customer’s name from the table.)
Unbound Unbound controls display information that doesn’t come from the
table – such as titles (e.g., ‘Hammer Wines Pty Ltd’), labels, and
graphics. Note that a label is paired with a bound control to tell
the user the name of the field.
Calculated With a calculated control the data for it doesn’t come directly
(created via a from the underlying table but from a calculation based on the
wizard) table. (E.g., our Service table holds “Units of Time” and if
multiplied by the MCFee it would equal Service Costs – more
about this later!)
Table 1 – Types of controls
Sections
A form can be in one or more sections – usually header, detail and footer
sections.
In form view you can scroll through the detail section keeping the header and
footer sections on the screen.
Data
The data from the table is displayed on the form with an accompanying
caption.
This is the caption you included in the properties for that field when you
created the table, or, the actual field name if you didn’t use a caption.
Labels
Labels such as “Hammer Wines Pty Ltd” and “Customer Form” are simply that
– labels. They are not connected with any underlying data.
Properties
We’ve already looked at properties when we designed the tables (input masks,
validation rules, etc).
Each object in a form has its own properties, too. Even the form itself. Think
of an object’s properties as the adjectives describing it (font, colour, position,
data source and so on).
Click on the bound control for CFirst with the right mouse button.
Select Properties and scroll through the properties describing this
object.
Try others.
With your Access file from the previous activity open and in Design view:
Adjust the length and the height of the form by clicking and dragging
the perimeter to give you more room to move.
You can select multiple objects by holding down the shift key as you
click on each object. We are going to group all the details for the
contact together.
Select all the fields concerning the contact person (CFirst, CLast,
Cmobile, CDirect, Email), select the Arrange toolbar, Control Layout
section, Remove.
You are now able to move these fields around the screen. With the
same fields still selected, move the mouse into the fields until you get
an arrow a little like this , and move them to the right of the
screen.
You are now able to individually adjust the size of these fields, swap
to the layout view, scroll to the last record, checking as to the
appropriateness of the field sizes, adjust as required.
Create a box around them (using the scroll bar at the end of the
Controls section to select the Rectangle icon (see Figure 3), now
position the cursor where you want the box to be, click and drag to
adjust the size).
Click on the label icon in the Design ribbon, Controls section, draw a
label above the contact details, enter the label – Contact Details.
To format this label, you must select the box, then change the font,
size and alignment.
The form should look like Figure 3.
In the Layout view (see Figure 6), adjust the size of the fields State and
PostCode, all fields will adjust together. To treat a field individually,
select the field, then select the Arrange ribbon, Table section,
Remove Layout. You will find as you remove them, they appear to
disappear from the screen. The fields are still there, but CPhone has
moved on top. Remove this; you will be able to drag these down a
little to reveal State and PostCode, now you can adjust the widths of
the fields.
Figure 6 - View options found on the Home ribbon or in the bottom right of your screen
Drag the ‘Detail’ bar slightly downward to create space for a header.
There is already a label/title on this form, it needs to be changed.
Click on the title, enter the new title for this form, Customers and
their Venues. Select an appropriate font type, size and alignment so it
will stand out. If you want to have a company name here, you can edit
the label.
We are going to add a logo to our forms. This can be either an existing image or you
can create your own. Your choice – Microsoft Clip Gallery, find something on the
web or use Google to find a free logo generator to create your own logo.
Delete the existing image. Use the image tool to draw a rectangle for
your graphic. Access want to know where to get the graphic from.
Navigate to where your image is stored.)
You may have to change one of its properties – the Size mode property. By default
the Size mode property is set to ‘Clip’, which means the graphic is cut to fit the frame
you’ve drawn, just as you might cut a photo to fit a frame, except Access doesn’t
keep the subject in the middle like you would.
Right mouse click on the image to bring up the shortcuts, select
Properties. The properties sheet dialog box should appear (see Figure
7
Click in Size Mode. Use the drop down arrow and choose ‘Stretch’. It
will size the graphic to fit the frame.
Did you know if you double click Access will scroll through the options, try it out!
Redesign your form to look like Figure 4.
Save. Access has already created a name for this form. Ensure the
name is Customers and Venues.
Activity 2
Command Buttons
To further help Marilyn and Colin Hammer, we will set up command buttons to
delete and print a record. These are record operations. Also, a button to close this
form would be useful. This is a form operation.
So it’s back to design view and the Design toolbar. This time it’s the Button (Form
Control). .
Click and draw the buttons at the bottom of the detail section. If there
isn’t enough room, drag the bottom of the section to increase the
size.
These buttons should print a record and close a form.
The Button (Form Control) tool starts up the command button wizard. The wizard
gives you a number of actions to choose from for your button. They are divided into
categories (see Figure 9). Choose appropriately for each of the buttons and answer
the questions as prompted by the wizard. Remember consistency in design helps the
user, so either use text or pictures, but not a combination both.
When all the buttons are created, you may need to use the Control Alignment and
Size buttons in the Arrange toolbar to tidy them up (see Figure 10).
Activity 3
Problem/Opportunity
Colin and Marilyn Hammer may need to change details/costing for both the TapType
costs and the Maintenance Contracts over time due to cost increases by suppliers or
wage pressures. We will create a form for the TapType table and another for the
MaintenanceContracts table.
TapType Form
This form will be a simple form and very easy to develop.
With the TapType table highlighted, go to the Create ribbon, click the
Form Wizard button as shown in Figure 11.
This will start a wizard that will step you through the process of creating a form. You
could experiment with the options available to you. If you don’t like what you have
created, don’t save it and go back to the start.
Click on >> to add all fields from the list of available fields. Click Next.
Accept the defaults by clicking Next twice, then Finish.
In Layout view , adjust the text box size.
Save the form as Tap Type Form.
We will add the command buttons to save a record. Go to the Design view and the
You can copy the logo from the form created in Activity 1 to this form. Hammer
Wines Pty Ltd want all the forms to have a similar appearance.
Open the Customers and Venues form in Design view, select the logo,
right click on the mouse to bring up the shortcut options and select
Copy.
In Design view of TapType form, click in the Form header and right
click your mouse, choose Paste.
This should paste the logo over the top of the existing label. We want to use that
label, so we need to tell Access to place the logo behind the label.
Once again, right-click the mouse, whilst the logo is selected, select
Position, Send to Back (see Figure 12).
Deselect the logo, select the label TapType. This label may need to be
moved to a more appropriate location; drag it to its new location.
Edit the Header to include a label for the form, Tap Type.
Add command buttons to Save the Record and Close the Form.
Activity 4
Problem/Opportunity
Venues will ring up to organise a maintenance repair for a particular tap. Colin and
Marilyn Hammer will need to have a simple means of entering maintenance details.
A form showing the Venue, Tap and Service history will be required.
This form would benefit from the addition of some additional venue details: Address,
Suburb, State, Venue Manager. In Design view:
Select the Venue textbox. Click on the Arrange toolbar, select
Remove from the Control Layout section.
Problem/Opportunity
Once Marilyn and Colin Hammer have become familiar with the database and what
it can do for them, they can allocate certain tasks to certain employees. At that
stage, we could set up user accounts and passwords for these employees, which will
restrict their activities in the database accordingly.
A User-Friendly System
One way to minimise the level of Access skill needed by Hammer Wines Pty Ltd
employees is to set up a ‘front-end’ for our database. This front-end or menu screen
will ensure staff have easy access to pre-existing forms, and later reports and
queries. These will need to be added at the end of the next workshop.
Also, if we put an extra button on each of our forms, returning the user to this Menu
screen, we will again make the system easier for the user. We can have the Menu
screen (it’s a form) appear on the screen as soon as the user starts the database, by
using a simple macro. If, at the same time, we maximise this form so that it fills the
screen, staff will have less exposure to the ‘nuts and bolts’ of Access, minimising the
chance of them accidentally doing something to put the database security or
integrity at risk.
Activity 5
A Menu-Driven System
The first thing we’ll do to make our system more user-friendly, where less Access
knowledge is required, is to create a Menu screen.
Set up buttons (Form Design Tools) Design Toolbar to access the forms created.
Queries and reports will be added later. Using the Button (Form Controls) tool:
Draw a button to allow the user to open each of the forms. They
should show all the records. This should start up the command
button wizard.
Remove the Footer area by dragging the lower handle up to the Form
Footer marker, until it is not visible.
We can make this possible for the user, by adding a ‘Close Form’ button on each of
our forms.
Open an existing form in design view.
Create a button using the Button in the toolbar.
Select Open form, and choose the MainMenu.
Label the button, Close Form.
Position it appropriately.
Activity 6
Autoexec Macro and Alternative Menus
Our system would be much improved if the first thing the user saw when they
started the database was our new Menu screen. We can achieve this by creating a
macro to open the form for us. A macro in Access is similar to the macros you may
have seen in Excel. It simply carries out, automatically, actions you might have done
yourself.
In this case, we’ll create a macro to open our Menu form and maximise it. If we
name this macro ‘Autoexec’, Access will automatically execute it when the database
is started. Autoexec is an especially named macro in Access, and Access knows
exactly what to do with it: run whatever commands the designer has instructed.
When you open a database, Access looks for a macro called ‘Autoexec’, to run. If
there isn’t one, it presents you with the main database window that we have
become very familiar with!
Using the Hammer Wines Pty Ltd file from the previous activity:
In the Create toolbar, click on the Macro icon (in the Other section).
Click in the Action column, choose Database Objects, OpenForm –
this is selected from the list of alternative actions found in the drop-
down list.
In the Action Arguments section (to left of the screen) the Form Name
should be set to MainMenu.
The second action should be set to Maximize, select this from the
Window Management optios. There are no Action Arguments for this
action. (See Figure 14.)
Save the macro as Autoexec and Close.
Extension Activity
Follow the instructions for Activity 3 to create a form for Maintenance Contracts.
Can’t remember how you did this? Go to Activity 3 page 8.
Add all the controls that are displayed in Figure 17; you may format the form as you
like.
Add a command button to the Main Menu to enable the end user to adjust contract
values as economic circumstances change. Forgotten how to do this? Go to page 7.
Skills Developed
You now know how to:
Create forms to make it easier to add and modify the data in our tables.
Modify the design of a form.
Create a main form/sub form that uses data from all of our tables via the
one-to-many relationship.
Add command buttons to a form.
Create a menu-driven system.
Create macros.
Create an autoexec macro.