Computer ScienceCore18 min read

Microsoft Access Forms and Reports

A screen for putting data in, and a page for getting it out

This topic appears in:

01

Two objects, two directions

A form is designed for the screen and for input: it presents one record at a time, laid out for a person who is typing. A report is designed for paper and for output: it presents many records at once, grouped, totalled and formatted to be read.

The distinction that matters in the exam: a form can change the data, a report cannot. A report is read-only by design, which is what makes it safe to hand to someone who should not be editing anything.

FormReport
Designed forthe screenprinting
Showsusually one record at a timemany records together
Can edit data?yesno — read only
Typical useentering a new studentthe end-of-term mark sheet
Grouping and totalsrarelythe main reason it exists
02

Why enter data through a form rather than the table

Data could be typed straight into the datasheet, so a form must earn its place. It does, for four reasons the exam asks for.

A form can show only the fields a particular user should see, and hide the rest. It can lay them out in the order of the paper form being copied from, which halves the mistakes. It can pull related data from several tables into one screen, so the user never has to know that the data is normalised across four tables. And it can use controls — a drop-down list of existing classes rather than a typed class name — which makes an invalid entry impossible rather than merely detected.

  • Text box — displays and edits one field.
  • Label — fixed text, such as a heading or a field caption.
  • Combo box / list box — choose from a list, usually drawn from another table.
  • Check box — a yes/no field.
  • Command button — runs an action: save, next record, open a report.
  • Subform — a form inside a form, showing the "many" side of a relationship.

Why a combo box beats a validation rule

A validation rule catches a wrong class name after it has been typed. A combo box listing the classes that exist means the wrong name cannot be typed at all — and it stores the underlying key while showing the readable name. Preventing an error is always better than detecting one, and this is the clearest example of it in the syllabus.

03

Forms with subforms

A single form handles one record of one table. Most real data entry involves a one-to-many relationship: an order and its several order lines, a student and their several enrolments.

A subform solves this. The main form shows the "one" record — the order — and the subform embedded inside it shows the related "many" records in a datasheet. Access links them on the shared key, so the subform automatically shows only the lines for the order currently displayed, and a new line entered there is automatically given the right foreign key.

Worked example

A shop needs a screen for taking an order: customer details at the top, and the items ordered below. Describe the design.

  1. Main form bound to the ORDER table, showing OrderNo, Date and the customer.One order is the "one" side, so it belongs on the main form.
  2. The customer chosen through a combo box listing existing customers.It stores CustomerID while showing the name, so the foreign key is always valid.
  3. A subform bound to ORDERLINE, linked on OrderNo.The many side goes in the subform, and the link means lines from other orders never appear.
  4. Within the subform, the product chosen by combo box and the quantity typed.Again the combo box makes an invalid product code impossible.
  5. A calculated control showing the line total, and another totalling the order.Calculated rather than stored, so it cannot disagree with the price and quantity it comes from.

Main form on ORDER with a combo box for the customer, and a subform on ORDERLINE linked by OrderNo.

04

Reports: grouping, sorting and totals

A report exists to make many records readable, and its power is in grouping. Grouping a mark sheet by class produces a heading for each class, its students listed beneath, and a subtotal or average at the end of each group before the next begins.

A report is built from named sections, and knowing which content goes in which section is the examinable part.

SectionPrintedPut here
Report Headeronce, at the very startthe title and the date produced
Page Headerat the top of every pagecolumn headings
Group Headeronce per groupthe class name
Detailonce per recordthe student's row
Group Footeronce per groupthe class subtotal or average
Page Footerat the bottom of every pagethe page number
Report Footeronce, at the very endthe grand total

The section decides how often it prints

A grand total placed in the Page Footer prints at the bottom of every page and is wrong on all but the last. Column headings placed in the Report Header appear once and are missing from page two onwards. When a report question asks where something belongs, it is really asking how many times it should appear — and the section name answers that directly.

Before you leave this chapter

  1. Forms are for input on screen; reports are for output on paper and cannot edit data.
  2. A form can hide fields, reorder them, combine tables and prevent invalid entry.
  3. A combo box prevents an invalid value instead of detecting it afterwards.
  4. A subform shows the "many" side of a relationship and sets the foreign key automatically.
  5. The report section determines how often its content prints: once, per page, per group or per record.

Practice questions

6 questions · 20 marks · full working on every one

Try each one on paper first, then open the working. The marks are shown where they are actually awarded, because that is where they are actually lost.

Short questions

3 · 6 marks

Two marks each, in the style of the short-question section of the paper. Answer in two or three lines.

SQ1[2 marks]
State two differences between a form and a report.
Model answer

A form is designed for the screen, usually shows one record at a time, and can edit the data. A report is designed for printing, shows many records grouped and totalled, and is read-only.

Examiner tip. The editing difference is the one the mark scheme always wants. Input against output is the other.

SQ2[2 marks]
Give two reasons for entering data through a form rather than directly into a table.
Model answer

A form can display only the fields a particular user should see and arrange them to match the paper form being copied from, reducing errors. It can also use controls such as a combo box, which makes an invalid entry impossible rather than merely detecting it afterwards.

Examiner tip. The combo box point is the strongest available, because preventing an error beats catching one.

SQ3[2 marks]
What is a subform used for?
Model answer

To display the "many" side of a one-to-many relationship inside the form showing the "one" side — the order lines within an order. Access links them on the shared key, so only the related records appear and new ones automatically receive the correct foreign key.

Examiner tip. The automatic foreign key is worth mentioning; it is the practical benefit rather than just the layout.

Solved numericals

2 · 8 marks

Full working, one step per line, with the marks shown where they are awarded.

N1[4 marks]
Name four sections of an Access report and state what should be placed in each.
Full working
  1. Report Header — the title and date, printed once at the very beginning[1]
  2. Page Header — column headings, printed at the top of every page[1]
  3. Detail — the fields of each record, printed once per record[1]
  4. Group Footer — a subtotal or average, printed at the end of each group; or Report Footer for the grand total[1]

Report Header, Page Header, Detail, Group and Report Footers — each printing at a different frequency.

Examiner tip. Say how often each prints. That is what makes the choice of section correct or incorrect.

N2[4 marks]
Explain why a combo box bound to a related table is better than a text box with a validation rule.
Full working
  1. A text box lets the user type anything, and the validation rule rejects it afterwards[1]
  2. A combo box offers only the values that exist, so an invalid entry cannot be made in the first placeprevention rather than detection[1]
  3. It can display a readable name while storing the underlying key value, so the foreign key is always valid[1]
  4. The list updates automatically when the related table changes, whereas a validation rule listing permitted values must be edited by handmaintenance is the fourth mark[1]

It prevents rather than detects, stores the key while showing the name, and stays current automatically.

Examiner tip. The maintenance argument is the one candidates miss: a hard-coded list of valid classes is wrong the day a new class is created.

Long questions

1 · 6 marks

Theory and numerical together, as they appear in the long-question section.

LQ1[6 marks]
A school needs a printed report showing every student's marks, grouped by class, with each class's average and an overall average.
  1. State which report sections you would use and what each contains.
  2. Explain why the overall average must not be placed in the Page Footer.
  3. Explain why a report rather than a form is the right object here.
Mark scheme
  1. Report Header: the title and the date produced. Page Header: column headings for name and marks[1]
  2. Group Header: the class name, printed once per classgrouping by ClassID[1]
  3. Detail: each student's name and marks, once per record[1]
  4. Group Footer: the class average. Report Footer: the overall average[1]
  5. The Page Footer prints at the bottom of every page, so an overall average placed there would appear repeatedly and be incorrect on every page but the last[1]
  6. A report is designed for printing many grouped records with totals, and is read-only — so it can be distributed without any risk of the marks being alteredthe read-only point is the strongest reason[1]

(a) header, page header, group header, detail, group footer, report footer (b) it would print once per page and be wrong (c) reports print many grouped records and cannot be edited

Examiner tip. The read-only argument in part (c) is the one worth leading with: a mark sheet handed to a class teacher must not be editable, and a form would be.