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.

The answer to the exercise will be included and explained if you attend the course listed below!

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

This page has 0 threads Add post