Creating a Custom Function

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


In the Visual Basic Editor, open a Modules window, click the Insert menu, and then click Procedure.


Enter the function's name.


Click the Function option.

graphics/4_icon.jpg Click OK.

The Editor inserts the opening and closing lines of your new custom function.


Enter variable names needed for the function.


Enter VBA commands required to calculate the function's value.


Insert a line assigning the calculated value to a variable with the same name as the function.


Show Me Microsoft Office Access 2003
Show Me Microsoft Office Access 2003
ISBN: 0789730049
EAN: 2147483647
Year: 2002
Pages: 318 © 2008-2017.
If you may any questions please contact us: