Access VBA Macros | Creating functions exercise | Calculate oscar success rate using function

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.

You can learn how to do this exercise on the relevant Wise Owl classroom training course (sadly for the moment only in the UK).

Software ==> Access VBA Macros  (25 exercises)
Version ==> Access 2010 and later
Topic ==> Creating functions  (4 exercises)
Level ==> Relatively easy
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.

Create a new module called modFunctions.

Create a function within this module to calculate the Oscar success rate for any film.  The inputs to your function will be:

  • The number of Oscar nominations for the film
  • The number of Oscar wins for the film

The output from your function is a single number, giving the win percentage (esssentially, one number divided by the other).  Be careful of films which didn't receive any Oscar nominations!

Test out your function using the immediate window:

Access VBA Macros exercise - Creating functions (image 1)

Three tests for your function - each time it is returning the correct percentage

Finally, create a new query incorporating your function to show for each film its Oscar success rate:

Access VBA Macros exercise - Creating functions (image 2)

How can a film win more oscars than it was nominated for? And how did the Matrix only win 4?

Save and close your module and query.

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