PC Review


Reply
Thread Tools Rate Thread

DoCmd.CopyObject method using variables

 
 
Alex
Guest
Posts: n/a
 
      18th Jul 2008
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

thanks

Alex


 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      18th Jul 2008
"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)

 
Reply With Quote
 
Alex
Guest
Posts: n/a
 
      18th Jul 2008
Thanks - changing strType to datatype integer works

Alex

"Dirk Goldgar" wrote:

> "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)
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
docmd.copyobject allen, gary Microsoft Access VBA Modules 5 22nd Apr 2010 06:07 PM
docmd.copyobject tted78 Microsoft Access VBA Modules 1 12th Sep 2008 12:07 PM
DoCmd.CopyObject =?Utf-8?B?QnJhZA==?= Microsoft Access VBA Modules 0 10th Mar 2006 02:55 PM
DoCmd.CopyObject Matt Microsoft Access Form Coding 1 21st May 2004 11:43 AM
Re: DoCmd.CopyObject question Jeff Boyce Microsoft Access 2 8th Aug 2003 01:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:51 PM.