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).

MethodArgumentsDescription
AddMenuMenuName, MacroName, StatusBarTextCreates a custom menu bar, shortcut bar, or shortcut menu.
ApplyFilterFilterName, WhereConditionApplies a filter, a query, or a SQL WHERE clause to a table, form, or report.
BeepNoneCauses the system to beep.
CancelEventNoneUsed to cancel the event that caused Access to run the macro or module containing this action.
ClearMacroErrorNoneClears the MacroError object and resets it to the default state.
CloseObjectType, ObjectName, SaveCloses the object specified in the ObjectName argument.
CloseDatabaseNoneCloses the current database.
CopyDatabaseFileDatabaseFileName, OverwriteExistingFile, DisconnectAllUsersCopies the database connected to the current project to a SQL Server database for export.
CopyObjectDestinationDatabase, NewName, SourceObjectType, SourceObjectNameCopies the specified object to another database (.mdb) or Access project (.adp).
DeleteObjectObjecType, ObjectNameDeletes 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.