O'Reilly logo

Access™ 2007 VBA Programmer's Reference by Armen Stein, Geoffrey Griffith, Rob Cooper, Teresa Hennig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required