OpenTable


Opens a table in the current database.

Syntax

DoCmd.OpenTable TableName[, View][, DataMode]

with the following parameters:

TableName

A String indicating the name of the table in the current database to open.

View

One of the following members of the AcView enumeration: acViewDesign (design view), acViewNormal (datasheet view, the default), and acViewPreview (print preview).

DataMode

A member of the AcOpenDataMode enumeration for tables opened in acNormal view. Possible values are acAdd, acEdit (the default), and acReadOnly.

Example

The example code iterates the AllTables collection, opens each nonsystem table, prints its structure, and then closes the open table.

Public Sub PrintTableStructures() Dim tbl As Variant For Each tbl In CurrentData.AllTables     If InStr(1, tbl.Name, "MSys", vbBinaryCompare) = 0 Then   DoCmd.OpenTable tbl.Name, acViewDesign   If MsgBox("Print table structure?", _   vbQuestion Or vbYesNoCancel, _   "Print Table Structure") = vbYes Then   DoCmd.PrintOut acPrintAll   End If   DoCmd.Close acTable, tbl.Name, acSaveNo   End If Next   End Sub

Comments

You can iterate the tables in the current database by using the CurrentData.AllTables collection. It includes system tables whose names begin with MSys…, however.




Access VBA Programming
Microsoft Access VBA Programming for the Absolute Beginner
ISBN: 1598633937
EAN: 2147483647
Year: 2006
Pages: 214
Authors: Michael Vine

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net