Team LiB
Previous Section Next Section

CopyObject

Copies a database object into the same or another database.

Syntax

DoCmd.CopyObject([DestinationDatabase][, NewName][, 

                 SourceObjectType][, SourceObjectName])

with the following parameters:

DestinationDatabase

The path and filename of the Access database to which the object is to be copied. If the current database, the argument should be omitted.

NewName

The name to be given the copy of the object. If it is to have the same name as SourceObjectName, this argument can be omitted.

SourceObjectType

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

SourceObjectName

The name of the object to be copied.

Example

Public Sub MakeBackupCopy()

   ' Make backup copy of Purchases table
   DoCmd.CopyObject , "tblPurchases Backup", acTable, "tblPurchases"
   ' Disable warnings
   DoCmd.SetWarnings False
   
   'Run update query to multiple prices by 10%
   DoCmd.OpenQuery "UpdatePrices"

   ' Turn warnings back on
   DoCmd.SetWarnings True

End Sub

Comments


Team LiB
Previous Section Next Section