Microsoft Access
Good programming techniques exercise
Average difficulty

This Microsoft Access GOOD PROGRAMMING TECHNIQUES exercise is provided to allow potential course delegates to assess their suitability for the Wise Owl ADVANCED VISUAL BASIC FOR APPLICATIONS course only, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

Exercise: Optional arguments - adding people

A full answer to this exercise is provided as part of the training course!

1) Download the files needed to start this exercise: exercise-612.zip (and click here if you experience any problems unzipping this file after downloading it).
2) Create an enumeration to hold the possible department ids:
Exercise screen-shot 2166 If your trainer has forgotten to tell you what an enumeration is, tell him/her off!
3) Write a macro to add a new person to your database.  You can assume that each person is in the Accounts department, which means setting the DepartmentId field to Department.Accounts.  You can ignore the Address field).  The macro should have two arguments:
  • FirstName - the person's first name
  • LastName - the person's last name
4) Test that your macro works by calling it from either the immediate window or from another subroutine to add the following people:
  • Basil Brush
  • Tom Thumb
5) Amend your subroutine so that, optionally, you can specify an extra argument giving the postcode.  This should default to NOT SET if not specified. Call this amended subroutine to add the following people:
  • Dave Cameron, W1
  • Susan Dunne, IP33
  • Luke Skywalker
6) If you have time, amend your macro so that you can also pass in (optionally) the department, which again defaults to Accounts:
Exercise screen-shot 2167 This is how you might call your amended subroutine
7) Save this module and close the database.

Thank you for showing an interest in this Advanced Visual Basic for Applications training course! As mentioned above, full answers to this and other exercises are provided on the course. On all Wise Owl scheduled courses delegates can take away these model answers (together with their own efforts!) on a free USB stick.

All content � Wise Owl Business Solutions Ltd 2007.  All rights reserved.  Design by Branches.