Avatar of FSOLL
FSOLLFlag for United States of America

asked on 

How to COPY from one recordset to another?

I have a recordset based on SQL connecting to AS400.  How can I COPY that recordset to a real Access table without having to read/write each field/record?  Anything similar to COPYRECORDSET in Excel???
Microsoft Access

Avatar of undefined
Last Comment
LennyGray
Avatar of LennyGray
LennyGray
Flag of United States of America image

Why copy the recordset when you can attach it?

By attaching the recordset, you get the benefit of all data changes as they happen without importing periodically and you get the structure automatically.

Lenny
Avatar of FSOLL
FSOLL
Flag of United States of America image

ASKER

Lenny, don't understand what you mean by attaching.
Need example code.
Thanks.
Avatar of LennyGray
LennyGray
Flag of United States of America image

Open your databse container to TABLES

Then follow the menu item:
File->Get External Data->Link Tables

When the Link Dialog appears, on the bottom ("Files of Type") select ODBC Databases.

The remainder depends upon your environment. The Access help files will show you how to link an external table.

Once the table is linked (my terminology....attached), you inherit the structure and have a "live" link to the table on the AS400.

You only need to link once, so code is not necessary unless you will dynamically link various additional tables.
Avatar of FSOLL
FSOLL
Flag of United States of America image

ASKER

I can't link to the AS400 because all I need is a subset (extract) of the table.  Right now I'm doing the connection with an SQL statement for the criteria I need.
That result recordset is what I want to copy to a permanent Access table without having to READ/WRITE one record at a time.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of LennyGray
LennyGray
Flag of United States of America image

FSOLL -

Use Jeff's solution for your immediate needs.

The reason that I suggested linking a table is that the nature of data is that when you perform an extract, the data is already obsolete. Data, by definition, is dynamic and ever-changing. So, every time that you want to examine your data, you would have to re-download an extract which has significant overhead, uses tremendous resources and takes a lot of time - especially if the table is huge.

If you linked a table, you could run your SQL statments or queries on the subset and you will be examining "fresh and current" data every time without invoking the extraction every time that you needed that data for your purposes. Remember, the size of a linked table has no impact on your Access database. You could even run yor SQL statements at the database server on the AS400 (by using stored procedures and triggers) and simply pass dynamically-extracted data to the Access application.

Just a thought.

Lenny

LennyGray,

Can you please stay on?
I sense that you have more experience with SQL.

My post assumes both tables are local.

I am not sure if you can point to a source from an AS400?

Jeff
SOLUTION
Avatar of LennyGray
LennyGray
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of LennyGray
LennyGray
Flag of United States of America image

FSOLL -

Has your question been clearly answered?


Lenny Gray
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo