Article ID: 97514 - Last Review: May 9, 2003 - Revision: 2.0 ACC: Writing Functions Called from Events or ExpressionsThis article was previously published under Q97514
Moderate: Requires basic macro, coding, and interoperability skills.
On This PageSUMMARY
Functions can be used in a variety of places in Microsoft Access. How
you write your functions depends on where the functions are going to
be called from.
This article assumes that you are familiar with Access Basic and with creating applications for Microsoft Access using the programming tools provided with Microsoft Access. MORE INFORMATION
There are two main styles for writing Access Basic functions:
The examples below use the Proper() function to illustrate the differences between the two function styles. Proper() converts the first letter of a word to uppercase and the other letters to lowercase. Calling a Function from an Event PropertyThe Proper() function can be written so it can be called from an event, such as the AfterUpdate property of a control on a form. In this example we will call it ProperAU() as a reminder that it should be called from the AfterUpdate property.Enter the following function in a module: Example
Calling a Function from an ExpressionThe Proper() function can be written so it can be called from an expression, or calculated control. In this example we will call it ProperCC() as a reminder that it should be used in calculations.Enter the following function in a module: Example
Determining the Type of Function You NeedWhere used Function style ----------------------------------------------------------- AfterUpdate, BeforeUpdate, and so on Event RunCode macro action Event Calculated controls on forms and reports Expression Calculated fields in a query Expression SetValue macro action expression Expression Default values in a table or form Expression Called from another function or sub Expression APPLIES TO
| Article Translations
|

Back to the top
