EXERCISE TOPIC▼
- Access exercises (91)
- C# exercises (79)
- Excel exercises (278)
- Power Apps exercises (13)
- Power Automate exercises (18)
- Power BI exercises (139)
- Power Platform exercises (157)
- Python exercises (28)
- Report Builder exercises (141)
- SQL exercises (198)
- SSAS exercises (51)
- SSIS exercises (46)
- SSRS exercises (99)
- VBA exercises (85)
- Visual Basic exercises (46)
ACCESS EXERCISES▼
ACCESS VBA MACROS EXERCISES▼
Access VBA Macros | Creating functions exercise | Write a function to show the Oscar hit rate for each film
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.
Software ==> | Access VBA Macros (25 exercises) |
Version ==> | Access 2010 and later |
Topic ==> | Creating functions (4 exercises) |
Level ==> | |
Subject ==> | Access training |
You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
The aim of this exercise is to create a function to show the success rate for each film (the number of Oscars it won, divided by the number it was nominated for):

A film clearly can't win more Oscars than it is nominated for, so the first row looks like an anomaly in the database!
To do this, create a function called OscarHitRate which takes two arguments:
Argument | What it will hold |
---|---|
1 | The number of Oscars won |
2 | The number of Oscar nominations |
Your function should return the percentage success rate (this will be a decimal number, which you'll then format in the query to look like a percentage).
Your function should return 0 if a film didn't get any nominations, to avoid any divide by zero error.
Test your function in the immediate window, then use it to create the query shown at the start of this exercise.
Save any open queries and modules, then close them down.