• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

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.

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.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint