- The function is called using VBA code (passing three parameters in the process),
- The function looks up information stored in an access table (based on the parameters passed),
- It then returns that information, storing the result in a variable called varResult.
|Figure 2: This is the form from which our function is called. The CORRECT ANSWERS textbox is called txtScore, No OF QUESTIONS is called txtOutOf, and the PERCENTAGE textbox is called txtPercentageResult. The CALCULATE button is called cmdCalculate.|
|Figure 3: The top window shows the code calling the myPercentage function. The lower window shows the code from the myPercentage function itself.|