Share via


Built-in Access Functions and Methods

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The Microsoft® Access Application object contains several functions and methods you can use to work with data, Access objects, or the application itself. These functions and methods appear in the Object Browser as methods of the Application object, although they might be referred to as "functions." These functions and methods can be used within Access or from another application by using Automation.

Calling Built-in Access Functions and Methods Without Using an Application Object Variable

To use Automation, you usually have to create an instance of the Application object, but you can call built-in Access functions and methods of the Application object from other Microsoft® Office applications without first creating an Access Application object variable. The only requirements are that you set a reference to the Microsoft® Access object library in the calling application's Microsoft® Visual Basic® for Applications (VBA) project, and that you call the function or method by using the Access qualifier, as illustrated in the following example. For example, you could use the following VBA code to call the built-in Access Eval function to evaluate a string expression contained in a Microsoft® Word bookmark:

Dim rngResults As Word.Range
Set rngResults = ActiveDocument.Bookmarks("MathMark").Range
rngResults.Text = Access.Eval(rngResults.Text)

Note   Direct calls to built-in Access functions and methods, such as the one illustrated in the preceding example, automatically create a new instance of Access that remains in memory until the document containing the code that called the function or method is closed. If you want more control over when the instance of Access is created and destroyed, create it by using the New keyword or the CreateObject or GetObject function, and close it by setting the Application object variable equal to Nothing.

The following table summarizes some of the Access functions and methods available to you from the Application object and descriptions of how they might be used.

Function or method Description
Domain aggregate functions A domain is simply a set of records defined by a table or query. You use domain aggregate functions to get statistical information about a set of records, for example, to count the number of records or to determine the sum of values in a particular field. These functions use a naming convention that begins with a capital "D", for example, DAvg, DCount, DLookup, DSum, and so on. You can use these functions in VBA code, in a query expression, or in a calculated control on a form or report.
Eval function You use this function to evaluate a string expression that results in a text string or numeric value. The Eval function uses a single argument that either is a string expression that returns a value or is the name of a built-in or user-defined function that returns a string. You can use the Eval function in a calculated control, a query expression, a macro, or VBA code.
GUIDFromString and StringFromGUID functions You use these functions to convert a globally unique identifier (GUID) to a String value or a String value to a GUID. A GUID is a 16-byte value used to uniquely identify an object.
hWndAccessApp method You can use this method to determine the handle (a unique Long Integer value) assigned by Microsoft® Windows® to the main Access window. You can use the hWnd property to determine the handle assigned by Microsoft Windows to an Access Form or Report window.
HyperlinkPart function The HyperlinkPart function returns information about data stored in a field that has the Hyperlink data type. This information is similar to the information contained in the properties of a Hyperlink object. You can use this function in VBA code, a query expression, or a calculated control.
LoadPicture method This method loads a graphic file stored on disk into the Picture property of a control. You use this method to set or change the Picture property of a control at run time.
Nz function You use the Nz function to evaluate a value and return a specified value if the evaluated value is Null. This function is useful when you are assigning values from a field in a recordset to a control that cannot use Null values.
SysCmd method This is the Swiss army knife of Access methods. It can perform a variety of tasks depending on the value of the acSysCmdAction constant supplied in its action argument. For example, you can use this method to display a progress meter or text in the status bar, return information about Access (such as the directory where Msaccess.exe is located), or to get information about an Access object (such as whether a form is open).

For more information about these functions and methods, search for them by name in the Microsoft® Access Visual Basic Reference Help index.

Note   In addition to working with built-in Access methods and functions, you can use the Application object's Run method to call custom procedures stored in an Access database.

See Also

Working with Microsoft Access Objects | Understanding the Access Application Object | Creating, Opening, and Closing an Access Application | The CurrentData and CurrentProject Objects | Working with the Screen Object | Working with the DoCmd Object | Working with the Modules Collection | Working with the References Collection | Working with Reports, Forms, and Data Access Pages | Office Objects and Object Models