Team LiB
Previous Section Next Section

Close

Closes the window of an Access object.

Syntax

DoCmd.Close([ObjectType][, ObjectName][, Save])

with the following parameters:

ObjectType

An AcObjectType constant indicating the type of object to close. Possible values are acDataAccessPage, acDefault (the active window), acDiagram, acForm, acFunction, acMacro, acModule (a VBA module), acQuery, acReport, acServerView, acStoredProcedure, and acTable.

ObjectName

A String indicating the name of an object of type ObjectType.

Save

An AcCloseSave constant indicating whether changes should be saved. Possible values are acSaveNo, acSavePrompt (the default value), and acSaveYes.

Example

The example iterates the AllTables collection to determine if a table is open. If it is, it prompts the user to close it.

Public Sub CloseTables()

Dim tbls As AllTables
Dim tbl As Variant

Set tbls = Access.Application.CurrentData.AllTables
For Each tbl In tbls
   If tbl.IsLoaded Then
      If vbYes = MsgBox("Close " & tbl.Name & "?") Then
         DoCmd.Close acTable, tbl.Name, acSavePrompt
      End If
   End If
Next

End Sub

Comments


Team LiB
Previous Section Next Section