You are on page 1of 23

Office 2010

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.

 Open Hammer2.accdb OR your copy of Hammer_xxx.accdb.

Customers and Venues: Main Form/Sub Form


Hammer Wines Pty Ltd has a requirement to see, on the screen, all venues operated
by a particular customer. To achieve this, we need to create what is called a main
form/sub form:
 The main form would hold details for one customer – this is the one side of
the relationship (Customers).
 Within, the sub form would hold details for all the venues operated by that
customer – this is the many side of the relationship (Venue).
 Access makes use of the one-to-many relationship we set up in the previous
workshop to build the main form/sub form.

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

Access Workshop 2 Page 1


Activity 1
Office 2010

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.

Figure 1 – Data view of a form

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
.

Access Workshop 2 Page 2


Activity 1
Office 2010

 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.

First, let’s study the design screen.

.
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.

Access Workshop 2 Page 3


Activity 1
Office 2010

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.

Access Workshop 2 Page 4


Activity 1
Office 2010

 Look at the properties for the form as a whole, by right-clicking on


the black square where the two rulers meet, at the top left-hand
corner of the form.

Redesign the Form


Now that we know all the important components of a form, let’s redesign the form.
Some information before we get started:
 We’ll use the control section to create the type of objects we want. E.g., we
need the logo tool to hold a graphic, and the label tool to set up a heading.
 All the objects on a form can be selected/moved/sized etc. just like any other
Windows objects. Use the shift key to select more than one object.
 You will need to switch between views quickly and easily to check on your
design, use the icons in the bottom right of the screen.

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).

Figure 3 - Design Controls

Access Workshop 2 Page 5


Activity 1
Office 2010

 Change the appearance of the rectangle by right mouse clicking to


bring up a series of shortcuts select Special Effect button, choose the:
Shadowed effect.

Figure 4 - Right mouse shortcuts

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.

Figure 5 – Design view of a form

 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,

Access Workshop 2 Page 6


Activity 1
Office 2010

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

Access Workshop 2 Page 7


Activity 1
Office 2010

Figure 7 - image Properties

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.

Figure 8 – Command button wizard

 Save. Access has already created a name for this form. Ensure the
name is Customers and Venues.

Access Workshop 2 Page 8


Activity 1
Office 2010

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.

Figure 9 – Command Button Wizard

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).

Access Workshop 2 Page 9


Activity 2
Office 2010

Figure 10 – Form with graphic and buttons

 Save your form.


Test it out!
 Add another venue associated with Aero Bar: Touch & Go, 345 Thrift
St, Badgerys Creek, NSW, 2555, (02) 9616 1233, Jilly Jones.
 Check the Venue table, this new data should have been added to it.

Access Workshop 2 Page 10


Activity 2
Office 2010

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.

Figure 11 – Form Wizard

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

Design toolbar. This time it’s the Button (Form Control). .


 Click and draw the button to the right of the detail section screen. If
there isn’t enough room, adjust the width of the textboxes.
A wizard will step you through the process of attaching the relevant commands to
the button. Remember, you need to think in terms of “what do I want this button to
do?” Is it a form operation or a record operation? The button should save the
record.

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.

Access Workshop 2 Page 11


Activity 3
Office 2010

Figure 12 – Logo positioning options

 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.

Figure 13 – Completed Tap Type form

Access Workshop 2 Page 12


Activity 3
Office 2010

 Save the changes you have made to the form.

Access Workshop 2 Page 13


Activity 3
Office 2010

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.

Taps Service Form


Follow the above steps in Activity 1 to create another main form with a sub form.
Remember that we have another one-to-many relationship between the Taps table
and the Service table.

Figure 14 – Main form/sub form

Note the changes to be made in Figure 14. In Layout view:


 Adjust the width of the textboxes in the Main form section.
 Adjust the column width in the Sub/form section so you can see all
the data.
 Delete exiting items in the form header
 The header can be copied from one form to another. Copy the header
(logo) from the Customers and Venues form, paste into the header
area of this form.
 Change the position of the logo to Send to Back.
 Add a new label - Taps Service Form, position appropriately.
Did you know you can centre data in a column by highlighting the column and
choosing the centre alignment option on the Home toolbar?

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.

Access Workshop 2 Page 14


Activity 4
Office 2010

 Move the Venue field to the right of screen.


 The Form Design Tools, Design ribbon, and from the Tools section –
select Add Existing Fields, show all Tables (see Figure 15).
 Double click on Venue.
 Add the field VAddress by double-clicking the field; this will place it on
your form.
 Move the textbox to the right of Venue.

Figure 15 – Additional Field List

 Repeat the last 2 steps to add VSuburb, VState, VP’Code, VContact


and VPhone.
 Align all these fields; draw a rectangle around the venue details.
 Add some command buttons to Find a record and Save the record as
well as Close the form. Remember, once you draw the command
button the wizard will commence to step you through all the actions.
 The date can be added to the header area by choosing Date and Time

from the Design Controls toolbar.

Access Workshop 2 Page 15


Activity 4
Office 2010

 Save this form as Taps Service Form.


Figure 16 is an example of the completed Taps Service Form.

Figure 16 – Another main form/sub form: Taps Service Form

Access Workshop 2 Page 16


Activity 4
Office 2010

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.

From this Menu, the user will be able to select:


 The data they want to maintain.
 The queries they want to run.
 The reports they want to print or preview.

Using the same Access file from the previous activity:


 Select the Create toolbar, Forms section, a Blank Form (not based on
any table or query).
 in Design view, right-click the mouse in the Detail section to bring up
the shortcut list, select Form Header/Footer.
 Copy the header from one of the other forms and put it on this form.
This form should have the title Main Menu.

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.

Access Workshop 2 Page 17


Activity 5
Office 2010

 Make sure the text on your buttons is meaningful to the user as to


what will happen once the button is clicked. See Figure 17.
 Save the finished form as MainMenu.
Test it out! Make sure the buttons work. Remember consistency in design is
important. Text is better on a main menu. Plan for extension, you will be creating
queries and reports in the next workshop and will need to add these to your main
menu.
 Add a rectangle to group the forms and an explanation (see Figure
17).

Figure 17 – Main Menu

 Remove the Footer area by dragging the lower handle up to the Form
Footer marker, until it is not visible.

Returning to the Menu


When you open a form (and later run a query, or preview a report) by clicking on a
button on the Menu screen, you need a button on that form that will automatically
return you to the Menu screen.

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.

Access Workshop 2 Page 18


Activity 5
Office 2010

Test it out! Place a main menu button on each form.


 Copy this button and paste onto each of forms, not including the
MainMenu.
 Save each form as you add the main menu button.

Access Workshop 2 Page 19


Activity 5
Office 2010

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.

Access Workshop 2 Page 20


Activity 6
Office 2010

Figure 18 – Macro design window

 Test it by closing your database and reopening it.

Access Workshop 2 Page 21


Activity 6
Office 2010

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.

Figure 19 – Completed contract pricing form

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.

Figure 20 – Completed Main Menu Form

Access Workshop 2 Page 22


Extension Activity
Office 2010

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.

Assignment – getting started

 Create a new database.


 Consider the design of your tables. Read the rest of the assignment to see
what fields other than those that are listed might be needed. Review
Activities 1 & 2 in Workshop 1.
 Design the table. Don’t use the table wizard. (Table/New/Design View.)
 Set up appropriate field names, captions and other properties.
 Enter a few records in each table to test out your validations.
 Create the relationships between the tables.
 Then enter the bulk of your data.

Access Workshop 2 Page 23


Skill Developed

You might also like