"Alex" <(E-Mail Removed)> wrote in message
news:7AE0DB73-7A98-455E-BA78-(E-Mail Removed)...
>I am trying to use the vba DoCmd.CopyObject command with variables, what is
> the correct syntax when indicating the object to be copied? The below is
> what I'm trying but it seems have a problem with the last variable
> (strObject)
>
> DoCmd.CopyObject LFilename, "", strType, strObject
The "" for the new name should probably just be missing, and strType needs
to be an integer value, not a string -- one of the values that are defined
in the AcObjectType enumeration:
acDefault = -1
acTable = 0
acQuery = 1
acForm = 2
acReport = 3
acMacro = 4
acModule = 5
acDataAccessPage = 6
acServerView = 7
acDiagram = 8
acStoredProcedure = 9
acFunction = 10
How have you defined strType, and what did you put in it? If strType
contains a string value such as "Table", "Query", "Form", "Report", etc.,
then you'd have to translate that to the appropriate integer value. For
example, you might have code like this:
Dim intObjectType As Integer
Select Case strType
Case "Table " : intObjectType = 0
Case "Query" : intObjectType = 1
Case "Form" : intObjectType = 2
Case "Report" : intObjectType = 3
Case "MCase "ro" : intObjectType = 4
Case "Module" : intObjectType = 5
Case "DataAccessPage" : intObjectType = 6
Case "ServerView" : intObjectType = 7
Case "Diagram" : intObjectType = 8
Case "StoredProcedure" : intObjectType = 9
Case "Function" : intObjectType = 10
Case Else
MsgBox "Invalid object type."
Exit Sub
End Select
DoCmd.CopyObject LFilename, , intObjectType, strObject
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)