msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Copy Access Query

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise
Author Message
bz



Joined: 04 Oct 2007
Posts: 55

PostPosted: Tue May 29, 2007 3:40 pm    Post subject: Copy Access Query Reply with quote

Hi,

I am trying to copy a bunch of queries from one MDB to another MDB.
Would you guys show me how to do this with VB6 please?

Thanks!

Archived from group: microsoft>public>vb>enterprise
Back to top
View user's profile Send private message
AMDRIT



Joined: 04 Oct 2007
Posts: 13

PostPosted: Mon Jun 11, 2007 3:50 pm    Post subject: Re: Copy Access Query Reply with quote

You can make use of DAO to do this.

The easiest way would be to loop over the QueryDefs collection.

It has been a while for me, but in essence it is like

dim qd as Querydef

for each qd in sourceDB.QueryDefs

dim newQD as QueryDef
set newQD = targetDB.CreateQueryDef

with newQD
.name = qd.Name
.source = qd.Source
end with

targetDB.queryDefs.add(newQD)

next


"bz" wrote in message @TK2MSFTNGP03.phx.gbl...
> Hi,
>
> I am trying to copy a bunch of queries from one MDB to another MDB.
> Would you guys show me how to do this with VB6 please?
>
> Thanks!
>
>
Back to top
View user's profile Send private message
bz



Joined: 04 Oct 2007
Posts: 55

PostPosted: Tue Jun 12, 2007 3:55 pm    Post subject: Re: Copy Access Query Reply with quote

Thanks for the tip... but can I use ADO? I don't remember how to do DAO
anymore.


"AMDRIT" wrote in message @TK2MSFTNGP02.phx.gbl...
> You can make use of DAO to do this.
>
> The easiest way would be to loop over the QueryDefs collection.
>
> It has been a while for me, but in essence it is like
>
> dim qd as Querydef
>
> for each qd in sourceDB.QueryDefs
>
> dim newQD as QueryDef
> set newQD = targetDB.CreateQueryDef
>
> with newQD
> .name = qd.Name
> .source = qd.Source
> end with
>
> targetDB.queryDefs.add(newQD)
>
> next
>
>
> "bz" wrote in message
> @TK2MSFTNGP03.phx.gbl...
>> Hi,
>>
>> I am trying to copy a bunch of queries from one MDB to another MDB.
>> Would you guys show me how to do this with VB6 please?
>>
>> Thanks!
>>
>>
>
>
Back to top
View user's profile Send private message
AMDRIT



Joined: 04 Oct 2007
Posts: 13

PostPosted: Tue Jun 12, 2007 6:17 pm    Post subject: Re: Copy Access Query Reply with quote

I don't believe you can, at least not laid out like I suggested, you would
have to work against the system tables in Access. Perhaps you could do
something with ADOX, but I don't know for sure.

There are still a lot of good reference material on DAO out on the web, the
choice is yours.

"bz" wrote in message @TK2MSFTNGP02.phx.gbl...
> Thanks for the tip... but can I use ADO? I don't remember how to do DAO
> anymore.
>
>
> "AMDRIT" wrote in message
> @TK2MSFTNGP02.phx.gbl...
>> You can make use of DAO to do this.
>>
>> The easiest way would be to loop over the QueryDefs collection.
>>
>> It has been a while for me, but in essence it is like
>>
>> dim qd as Querydef
>>
>> for each qd in sourceDB.QueryDefs
>>
>> dim newQD as QueryDef
>> set newQD = targetDB.CreateQueryDef
>>
>> with newQD
>> .name = qd.Name
>> .source = qd.Source
>> end with
>>
>> targetDB.queryDefs.add(newQD)
>>
>> next
>>
>>
>> "bz" wrote in message
>> @TK2MSFTNGP03.phx.gbl...
>>> Hi,
>>>
>>> I am trying to copy a bunch of queries from one MDB to another MDB.
>>> Would you guys show me how to do this with VB6 please?
>>>
>>> Thanks!
>>>
>>>
>>
>>
>
>
Back to top
View user's profile Send private message
Douglas J. Steele



Joined: 04 Oct 2007
Posts: 80

PostPosted: Sun Jun 17, 2007 11:43 pm    Post subject: Re: Copy Access Query Reply with quote

The QueryDef object doesn't have a Source property. Perhaps you're thinking
of the SQL property:

With newQD
.Name = qd.Name
.SQL = qd.SQL
End With

Don't forget, too, that there could be pass-through queries. In that case,
you'd also want to copy the Connect property.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"AMDRIT" wrote in message @TK2MSFTNGP02.phx.gbl...
> You can make use of DAO to do this.
>
> The easiest way would be to loop over the QueryDefs collection.
>
> It has been a while for me, but in essence it is like
>
> dim qd as Querydef
>
> for each qd in sourceDB.QueryDefs
>
> dim newQD as QueryDef
> set newQD = targetDB.CreateQueryDef
>
> with newQD
> .name = qd.Name
> .source = qd.Source
> end with
>
> targetDB.queryDefs.add(newQD)
>
> next
>
>
> "bz" wrote in message
> @TK2MSFTNGP03.phx.gbl...
>> Hi,
>>
>> I am trying to copy a bunch of queries from one MDB to another MDB.
>> Would you guys show me how to do this with VB6 please?
>>
>> Thanks!
>>
>>
>
>

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group