Tuesday, July 29, 2014

How To Creating a Custom Function in Access 2003

In addition to Sub procedures, you can also create function procedures that Access uses as custom functions. Each function procedure begins with the line: FunctionName( ) where FunctionName is the name of the function procedure. Within the parentheses, place any variables needed for the calculation of the function. You can learn more about variables from Access's online Help. After statement of the function's name and variables, add VBA commands to calculate the result of the function. The function concludes with the End Function line.

Create a Custom Function


graphics/1_icon.jpg
In the Visual Basic Editor, open a Modules window, click the Insert menu, and then click Procedure.
graphics/2_icon.jpg
Enter the function's name.
graphics/3_icon.jpg
Click the Function option.
graphics/4_icon.jpg Click OK.
The Editor inserts the opening and closing lines of your new custom function.
graphics/5_icon.jpg
Enter variable names needed for the function.
graphics/6_icon.jpg
Enter VBA commands required to calculate the function's value.
graphics/7_icon.jpg
Insert a line assigning the calculated value to a variable with the same name as the function.
graphics/14inf07.jpg