DoCmd.CopyObject (Access)
The CopyObject method carries out the CopyObject action in Visual Basic.
You can use the CopyObject action to copy the specified database object to a different Access database or to the same database or Access project (.adp) under a new name. For example, you can copy or back up an existing object in another database or quickly create a similar object with a few changes. You must include either the DestinationDatabase or NewName argument or both for this method. If you leave the SourceObjectType and SourceObjectName arguments blank (the default constant, acDefault, is assumed for SourceObjectType), Access copies the object selected in the Database window. To select an object in the Database window, you can use the SelectObject action or SelectObject method with the InDatabaseWindow argument set to Yes (True). If you specify the SourceObjectType and SourceObjectName arguments but leave either the NewName argument or the DestinationDatabase argument blank, you must include the NewName or DestinationDatabase argument's comma. If you leave a trailing argument blank, don't use a comma following the last argument that you specify.
CopyObject (DestinationDatabase, NewName, SourceObjectType, SourceObjectName)
DoCmd.CopyObject, "Employees Copy", acTable, "Employees"
Arguments
Optional arguments
The following arguments are optional
DestinationDatabase (String) - A string expression that's the valid path and file name for the database that you want to copy the object into. To select the current database, leave this argument blank. NOTE: In a Microsoft Access project (.adp), you must leave the DestinationDatabase argument blank. If you execute Visual Basic code containing the CopyObject method in a library database and leave this argument blank, Access copies the object into the library database.
NewName (String) - A string expression that's the new name for the object that you want to copy. To use the same name if you are copying into another database, leave this argument blank.
SourceObjectType (AcObjectType) - An AcObjectType constant that represents the type of object to copy.
Here you can find possible values for
SourceObjectName (String) - A string expression that's the valid name of an object of the type selected by the SourceObjectType argument. If you run Visual Basic code containing the CopyObject method in a library database, Access looks for the object with this name first in the library database, and then in the current database.