Forms and Subforms
Forms and Subforms
is called Tablet.
Field Properties
:1/=i'-.. ,-.,
Field ProptrtJH
frext Aliqn General !
-
I ,?. : Help,
i
I=
·t1
:z Afield name can be up to 64 characters long,
including spaces. Press F1 for help on rield names.
Fig 8.9 Entering the design of the Customer table
IT
3 Double-click on the Customer, Product and
2 Create the database called Sports, and then
M
Order tables. When you have finished adding the create the two tables.
O
tables, click Close.
3 Link the tables using a common primary key
4 N ow click on the. CID field in the Customer ,and
enter the data in each table.
table and drag it to the CID field in the
Order table.
5 An Edit Relationships window pops up
(Fig 8.12). Make sure the Enforce Referential
Integrity option is ticked in the checkbox and
press OK. This means that Access will help you
enforce rules so that your data is valid to start
with and remains valid throughout its use.
Edit Relationships ? X
Table/Query: I I
=v) I
Related Table/Query:
Create
jcust~~e!: ~: ~rder = I
loo
J
-cancel
/ 112
CID • Last First • IClick to Add .
.. John Rich
1124 Aks Todd
11 28 Tedd Lo u
1138 Yod
1 145 Ki ng
Microsoft Access X
116 7 Wa ll
1170 Cain )l Custo me r IDs start at 1000
* ( OK
I I .!::!elp
Num Lock
6 Select the Product table and double-click to open more complex forms. First, follow these steps to
it. create a basic form:
7 Enter the following records:
1 Open the Bookshop database with the Customer,
PR-ID Description Cost Product and Order tables. Each table should have
P3122 Pocket Diary $8.95 three records of data.
P3429 Jumbo Clips $4.15 2 Select the Customer table. Then in the menu or
P3430 Small Clips $2.75 ribbon, select the Create tab and then the Form
8 Select the Order table and double-click to open it. icon Form.
9 Enter the following records: 3 This option creates a simple form using all of the
fields in the table.
Customer ID Product ID QTY Discount
4 Use the form to enter the following records in the
1128 P3430 10
Customer table:
1128 P3639 500 y
1128 P3902 50 CID Last First
1138 Yod Ed
Exercise 6: Create a basic form 1145 King Bev
Microsoft Access does a very good job of creating a 1167 Wall Ann
1170 Cain Zed
form, and even provides a Form Wizard for creating
• Exercise 7: Create a form using the wizard
1 Select the Product table. Then activate the Form drop-down menu. To select the fields you want to
Wizard. In some versions of Access, there may be VIew on your form use the > arrow to move thern
an icon Ci Form Wizard , which can also be found in from the Available Fields window in the left
the More Forms option on the ribbon. pane to the Selected Fields window in the right
2 Select the fields needed for the form by selecting pane. You would use >> if you are selecting all of
a table or query from the Tables/Qyeries them (Fig 8.18).
Form Wizard
Iables/Queries
/Table: Product
El
6vailable Fields: ,S.elected Fields:
Desrnpt1on Pf?-ID
Cost
3 Click Next.
4 Select the layout you wish and click Next. Exercise 8: Completing the data entry with the
5 You may be asked to select the style you desire. Use a Order ta ble
light background if you are going to print your form. 1 Use the Form Wizard or another method to
6 Click Next. enter the following data in the Order table:
7 Give your form the name Product and click Finish. Customer Product QTY Discount
8 You should see your form. ID ID
9 . Enter the following data using the form: 1138 P3745 100
1145 P3122 5
PR-ID Description Cost
1167 P3430 10
P3639 Round Labels $3.95
1167 P3639 100 Yes
P3745 Receipt Book $7.55
so that the fields are selected in the following You cz,n choose from more than one table or query.
order:
a Select the Order Table and add the CID and I ables/Querles
-B
b Select the Product Table and add the ..,
Description and Cost fields.
c Select the Order Table again and add the
0
QTY and Discount fields. EJ
5 Click Next.
6 If prompted, view the data by Customer. You cancel 11 < ~ack [I Next > 11 f inish
in the PR-ID and enter P3745. The Customer Fig 8. 19b Viewing the data by Customer - you can see the form and
ID, description and cost of that product should sub-form in the preview pane
Fo rm Wizard
Form: lc§omerFonn-~ ~ ~ ~ ~ - -
Subform : [order Subfi>~-
Till!t's Ill the lnfomulllon the wlmrd needs to aellte your fonn.
rC:;~:e;Form
Fig 8.19c Naming the form and sub-form
X
CID
First
La st ~ edd
Order
Custom, • Product II • Description • Cost • QTY • J Discount .
_lms ffl30 Small ~ - $2.75 10
1128 P3639 Ro und Labels $3.95 500 0
1128 P3902 BlaclcPen $1.25 50
Record: H li""ot 7
e::ig 8. 79d The nna/ form showing the orders for customer Lou Ted