G.6. The DoCmd Object
In many regards, the DoCmd object is the workhorse of the Access object model. It carries out tasks such as exporting objects to different formats, opening objects, and manipulating the size of the Access window. It has no properties, but it does have a variety of methods you can utilize within your Access application.
All of the methods carry out an action with the same name as the method, so the following table provides descriptions of those actions, rather than of the methods (which merely call the actions).
Method | Arguments | Description |
---|---|---|
AddMenu | MenuName, MacroName, StatusBarText | Creates a custom menu bar, shortcut bar, or shortcut menu. |
ApplyFilter | FilterName, WhereCondition | Applies a filter, a query, or a SQL WHERE clause to a table, form, or report. |
Beep | None | Causes the system to beep. |
CancelEvent | None | Used to cancel the event that caused Access to run the macro or module containing this action. |
ClearMacroError | None | Clears the MacroError object and resets it to the default state. |
Close | ObjectType, ObjectName, Save | Closes the object specified in the ObjectName argument. |
CloseDatabase | None | Closes the current database. |
CopyDatabaseFile | DatabaseFileName, OverwriteExistingFile, DisconnectAllUsers | Copies the database connected to the current project to a SQL Server database for export. |
CopyObject | DestinationDatabase, NewName, SourceObjectType, SourceObjectName | Copies the specified object to another database (.mdb) or Access project (.adp). |
DeleteObject | ObjecType, ObjectName | Deletes the specified ... |
Get Access™ 2007 VBA Programmer's Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.