PC Review


Reply
Thread Tools Rate Thread

Append recordset to table

 
 
=?Utf-8?B?R2Vvcmdl?=
Guest
Posts: n/a
 
      17th Jun 2005
I have a VBA question. In my program, I create a recordset through SQL
(contained in strSQL) as follows:

Set rstSQL = myODBC.OpenRecordset(strSQL)

Now I would like to append the result of this recordset to a table in
Access. Is there an efficient way to do this? For example:
db.INSERT rstSQL into tblResult (obviously this won't work, but it's what I
want!)

Thanks,
George

 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      17th Jun 2005
You don't need the select query you are using. Make it into an append query
that pulls the records based on the criteria in your select query and appends
to your Access table.

So instead of:
Set rstSQL = myODBC.OpenRecordset(strSQL)
You would need
Currentdb.Execute(newSQL)

"George" wrote:

> I have a VBA question. In my program, I create a recordset through SQL
> (contained in strSQL) as follows:
>
> Set rstSQL = myODBC.OpenRecordset(strSQL)
>
> Now I would like to append the result of this recordset to a table in
> Access. Is there an efficient way to do this? For example:
> db.INSERT rstSQL into tblResult (obviously this won't work, but it's what I
> want!)
>
> Thanks,
> George
>

 
Reply With Quote
 
=?Utf-8?B?R2Vvcmdl?=
Guest
Posts: n/a
 
      17th Jun 2005
The query I have defined in strSQL is a pass-through query to a DB2 database.
Access cannot run it and an append query at the same time. Is there another
way?

Thanks

"Klatuu" wrote:

> You don't need the select query you are using. Make it into an append query
> that pulls the records based on the criteria in your select query and appends
> to your Access table.
>
> So instead of:
> Set rstSQL = myODBC.OpenRecordset(strSQL)
> You would need
> Currentdb.Execute(newSQL)
>
> "George" wrote:
>
> > I have a VBA question. In my program, I create a recordset through SQL
> > (contained in strSQL) as follows:
> >
> > Set rstSQL = myODBC.OpenRecordset(strSQL)
> >
> > Now I would like to append the result of this recordset to a table in
> > Access. Is there an efficient way to do this? For example:
> > db.INSERT rstSQL into tblResult (obviously this won't work, but it's what I
> > want!)
> >
> > Thanks,
> > George
> >

 
Reply With Quote
 
Rick Brandt
Guest
Posts: n/a
 
      17th Jun 2005
George wrote:
> The query I have defined in strSQL is a pass-through query to a DB2
> database. Access cannot run it and an append query at the same time.
> Is there another way?


Use the Pass-Through as the input to the append query.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


 
Reply With Quote
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      17th Jun 2005
Sorry, I should have known. But, I don't think there is that big a problem.
A query can be based on a query. Have you tried creating the append query
and use your pass-through as the source?

"George" wrote:

> The query I have defined in strSQL is a pass-through query to a DB2 database.
> Access cannot run it and an append query at the same time. Is there another
> way?
>
> Thanks
>
> "Klatuu" wrote:
>
> > You don't need the select query you are using. Make it into an append query
> > that pulls the records based on the criteria in your select query and appends
> > to your Access table.
> >
> > So instead of:
> > Set rstSQL = myODBC.OpenRecordset(strSQL)
> > You would need
> > Currentdb.Execute(newSQL)
> >
> > "George" wrote:
> >
> > > I have a VBA question. In my program, I create a recordset through SQL
> > > (contained in strSQL) as follows:
> > >
> > > Set rstSQL = myODBC.OpenRecordset(strSQL)
> > >
> > > Now I would like to append the result of this recordset to a table in
> > > Access. Is there an efficient way to do this? For example:
> > > db.INSERT rstSQL into tblResult (obviously this won't work, but it's what I
> > > want!)
> > >
> > > Thanks,
> > > George
> > >

 
Reply With Quote
 
George Nicholson
Guest
Posts: n/a
 
      17th Jun 2005
Assign your 1st SQL to a named querydef rather than a recordset. Then create
a 2nd SQL string that appends the querydef to your table?

--
George Nicholson

Remove 'Junk' from return address.


"George" <(E-Mail Removed)> wrote in message
news:618780E3-EDCB-4AD0-A337-(E-Mail Removed)...
> The query I have defined in strSQL is a pass-through query to a DB2
> database.
> Access cannot run it and an append query at the same time. Is there
> another
> way?
>
> Thanks
>
> "Klatuu" wrote:
>
>> You don't need the select query you are using. Make it into an append
>> query
>> that pulls the records based on the criteria in your select query and
>> appends
>> to your Access table.
>>
>> So instead of:
>> Set rstSQL = myODBC.OpenRecordset(strSQL)
>> You would need
>> Currentdb.Execute(newSQL)
>>
>> "George" wrote:
>>
>> > I have a VBA question. In my program, I create a recordset through SQL
>> > (contained in strSQL) as follows:
>> >
>> > Set rstSQL = myODBC.OpenRecordset(strSQL)
>> >
>> > Now I would like to append the result of this recordset to a table in
>> > Access. Is there an efficient way to do this? For example:
>> > db.INSERT rstSQL into tblResult (obviously this won't work, but it's
>> > what I
>> > want!)
>> >
>> > Thanks,
>> > George
>> >



 
Reply With Quote
 
=?Utf-8?B?R2Vvcmdl?=
Guest
Posts: n/a
 
      17th Jun 2005
Thanks for the idea - all three replies suggest the same approach: define an
append query that uses the pass-through query as the source. In VBA, how do
I do this with recordsets? I already have rstSQL.

Something like this?:
strSQL2 = "SELECT * FROM " & rstSQL & " INTO [TblResult]"
db.Execute(strSQL2)

Thanks

"Klatuu" wrote:

> Sorry, I should have known. But, I don't think there is that big a problem.
> A query can be based on a query. Have you tried creating the append query
> and use your pass-through as the source?
>
> "George" wrote:
>
> > The query I have defined in strSQL is a pass-through query to a DB2 database.
> > Access cannot run it and an append query at the same time. Is there another
> > way?
> >
> > Thanks
> >
> > "Klatuu" wrote:
> >
> > > You don't need the select query you are using. Make it into an append query
> > > that pulls the records based on the criteria in your select query and appends
> > > to your Access table.
> > >
> > > So instead of:
> > > Set rstSQL = myODBC.OpenRecordset(strSQL)
> > > You would need
> > > Currentdb.Execute(newSQL)
> > >
> > > "George" wrote:
> > >
> > > > I have a VBA question. In my program, I create a recordset through SQL
> > > > (contained in strSQL) as follows:
> > > >
> > > > Set rstSQL = myODBC.OpenRecordset(strSQL)
> > > >
> > > > Now I would like to append the result of this recordset to a table in
> > > > Access. Is there an efficient way to do this? For example:
> > > > db.INSERT rstSQL into tblResult (obviously this won't work, but it's what I
> > > > want!)
> > > >
> > > > Thanks,
> > > > George
> > > >

 
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
Recordset - looping thru to append to another table Billp Microsoft Access VBA Modules 2 20th Aug 2009 08:52 AM
How to do an append query to a table from a recordset magicdds- Microsoft Access VBA Modules 2 1st May 2008 01:51 AM
Using SQL statement to append a recordset to a table =?Utf-8?B?SGFyb2xkIERlTW9veQ==?= Microsoft Access Form Coding 5 19th Feb 2005 02:38 AM
Append ADO recordset to JET table Kenny-Z Microsoft Access Form Coding 0 14th Jan 2004 05:32 AM
loop through recordset and append data to a table Julie Microsoft Access VBA Modules 5 8th Oct 2003 12:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:57 PM.