OpenTable Method

Applies To

DoCmd Object.

Description

The OpenTable method carries out the OpenTable action in Visual Basic. For more information on how the action and its arguments work, see the action topic.

Syntax

DoCmd.OpenTable tablename [, view] [, datamode]

The OpenTable method uses the following arguments.

Argument

Description

tablename

A string expression that is the valid name of a table in the current database.

If you execute Visual Basic code containing the OpenTable method in a library database, Microsoft Access looks for the table with this name first in the library database, then in the current database.

view

One of the following intrinsic constants:

acNormal
acDesign
acPreview

acNormal opens the table in Datasheet view.

If you leave this argument blank, the default (acNormal) is assumed.

datamode

One of the following intrinsic constants:

acAdd
acEdit
acReadOnly

If you leave this argument blank, the default (acEdit) is assumed.


Remarks

If you specify the datamode argument and leave the view argument blank, you must include the view argument’s comma. If you leave a trailing argument blank, don’t use a comma following the last argument you specify.

See Also

DoCmd Object, OpenTable Action.

Example

This example opens the Employees table in Print Preview.


DoCmd.OpenTable "Employees", acPreview