WISE OWL 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.
The answer to the exercise will be included and explained if you attend the course listed below!
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.