Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
395 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
| Software ==> | Access VBA Macros (25 exercises) |
| Topic ==> | Creating functions (4 exercises) |
| Level ==> | Relatively easy |
| Subject ==> | Access training |
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
The aim of this exercise is to show a list of actors who are no longer with us, sorted by how long they were alive:

Whoever knew Zsa Zsa lived so long?
To do this, create a function called YearsLived which will have two input arguments:
| Argument | What it will hold |
|---|---|
| BirthDate | The date someone was born |
| DeathDate | The date someone died |
Think carefully not only what data type you should assign to these arguments, but also what data type the function should return.
Use the DATEDIFF function to determine someone's lifespan in years from these two bits of information, and return this from your function. The syntax is:
Test that your function works in the immediate window, then incorporate it into a query to show the years each actor was alive (only shows actors whose DoD field is not null). Zsa Zsa Gabor lived the longest; who lived the shortest number of years?
Save and close any queries, modules or tables you have open.
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2026. All Rights Reserved.