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
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

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):

Oscar hit rate

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. 

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 0 threads Add post