473,803 Members | 2,949 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy Contents of Recordset to a table

Hi,

I have a DB on a remote share that I want to update to a local DB
periodically. My plan is to create a VBA procedure and then trigger the
procedure a few times a day to the process is automated. My question is
how do I copy the contents of a Record set to a Table. This is what I
have so far:

Sub ImportDecap()

Dim Conn As New ADODB.Connectio n
Dim rst As New ADODB.Recordset
Dim strDB As String

strDB = "\\RemoteSVR\Re moteDir\MyDB.md b"

Conn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & strDB & ";"
rst.Open "SELECT * FROM t_journal_uploa d_data", Conn
'What I have tried is
Conn.Execute _
"INSERT INTO Table_in_Local_ DB VALUES " & rst.Fields(1)

But recieve an error so obviously I'm wrong. Has anybody any
suggestions of how this can be done?

Thanks

PC

May 29 '06 #1
5 12812
pa*****@gmail.c om wrote:
Hi,

I have a DB on a remote share that I want to update to a local DB
periodically. My plan is to create a VBA procedure and then trigger
the procedure a few times a day to the process is automated. My
question is how do I copy the contents of a Record set to a Table.
This is what I have so far:

Sub ImportDecap()

Dim Conn As New ADODB.Connectio n
Dim rst As New ADODB.Recordset
Dim strDB As String

strDB = "\\RemoteSVR\Re moteDir\MyDB.md b"

Conn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & strDB & ";"
rst.Open "SELECT * FROM t_journal_uploa d_data", Conn
'What I have tried is
Conn.Execute _
"INSERT INTO Table_in_Local_ DB VALUES " & rst.Fields(1)

But recieve an error so obviously I'm wrong. Has anybody any
suggestions of how this can be done?

Thanks

PC


This is not a great place to use a Recordset. Just link to the external table
and THEN an append query will work.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
May 29 '06 #2
If I go this route what are the access rules for linked tables i.e.
will the linked table update each time the append query is run, does it
update immediately a change is made on in the DB that holds the linked
table or is there some other rule that applies?

Thanks in advance

May 29 '06 #3
I tried this and I'm hoping there is a quicker way to achive this. The
remote DB is on a remote share and connection speeds aren't create. one
of the uses of the DB on the remote share is to serve as a central
point for dynamic tables that are used in excel by variuos users in
various locations. Using Recordsets I pull approx 7000 rows of Data
from the remote db directly into an Excel table on the client. This
takes approx 45 second.

When i try to refresh the linked table in access this takes over a
minute so would a recordset not be better in this instance?

Thanks

Paul

May 29 '06 #4
pmc1 wrote:
I tried this and I'm hoping there is a quicker way to achive this. The
remote DB is on a remote share and connection speeds aren't create.
one of the uses of the DB on the remote share is to serve as a central
point for dynamic tables that are used in excel by variuos users in
various locations. Using Recordsets I pull approx 7000 rows of Data
from the remote db directly into an Excel table on the client. This
takes approx 45 second.

When i try to refresh the linked table in access this takes over a
minute so would a recordset not be better in this instance?

Thanks

Paul


Why refresh it? If you create it once you should be done (unless the location
changes).

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
May 29 '06 #5
"pmc1" <pa*****@gmail. com> wrote in news:1148917674 .126685.241810
@j73g2000cwa.go oglegroups.com:
I tried this and I'm hoping there is a quicker way to achive this. The
remote DB is on a remote share and connection speeds aren't create. one
of the uses of the DB on the remote share is to serve as a central
point for dynamic tables that are used in excel by variuos users in
various locations. Using Recordsets I pull approx 7000 rows of Data
from the remote db directly into an Excel table on the client. This
takes approx 45 second.

When i try to refresh the linked table in access this takes over a
minute so would a recordset not be better in this instance?


Have you tried DoCmd.TransferS preadsheet?

While this command is not fast its use would do away with intermediate
databases and intermediate recordsets. You should be able to just create an
instance of an access application, open the remote db with that (nothing
will show), do the Transfer (AcExport) and close the application instance.
TTBOMK this will create the worksheet in the existing Excel file, or write
over it if it (the worksheet not the file) already exists.

In many years of working with Access I can think of only two cases where
recordset manipulation may have been the best way; one was because I was
using someone else's bastard normalization scheme and the other, my own, I
ditched and retreated to user-defined SQL Server function; it was slower
but cleaner.

999 times out of a 1000
RecordSet = Inefficency

Of course, I may totally misunderstand what you are trying to do.

--
Lyle Fairfield
May 29 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8375
by: Tlm | last post by:
Hello All, I have a form (FrmA) with a subform (SubFrmB) embedded in it. SubFrmB also has a subform embedded in it (SubFrmC) The form's recordsource is based on a table (TblA). SubFrmB's recordsource is also based on a table (TblB). SubFrmC's recordsource is also based on a table (TblC). There is a one-to-many relationship between TblA (one) and TblB (many).
6
1796
by: Geir Baardsen | last post by:
Hi! This is a routine for copying a recordset into a new order. It has worked fine under Win98. However, my client has changed to Win XP, and suddenly it doesn't work anymore. I keep getting the following error message: Object is not in collection. So I do a very thorough check and doublecheck of fieldnames from underlying table, tblOrderDetails. I even write them down in NotePad, and compares them... but there is no difference. I even...
2
2237
by: Ken | last post by:
How can I copy data from SQL to MS Access using dsn-less connection and not using SQL DTS? I have this but am stuck. I just want to do an export but can't figure out how to do a "select into". It pastes the data in SQL instead of access. The below code will cycle but I will have to create a table to place the data first. Is there an easier way. Sub getTables() Dim cnnSQL As ADODB.Connection Dim cnnMSA As ADODB.Connection
3
3219
by: david | last post by:
Hi, I've been reading tons of posts on how to copy records, but to no avail....i'm still stuck. There are three tables: Main, Sub-Form1 & Sub-Form2 I have a form which displays some data. The PK (ProductID) for each record on the form is an AUTONUMBER. This form also has a sub-form, linked via ProductID. The subform also
7
11645
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
1
2198
by: Beowulf | last post by:
I have a report laid out in Design View as shown at the end of this message. I have code that performs the following steps: 1. In main report's Report_Open(), DELETE any old rows in tblTOC for this username. 2. In main report's CategoryHeader_Format(), add a row to tblTOC with the current category name and the current page number. 3. In the table of contents subreport, Cancel if NoData event fires.
4
4979
by: Jim Devenish | last post by:
I wish to copy a table on a SQL Server backend to a table on an Access (.mdb) front end in the simplest way. I have the following to get the recordset but am seeking something easier. Dim theConnectionString theConnectionString = "Driver=SQL Server; Server=Server;Database=myData;Trusted_Connection=Yes"
2
9295
by: mustang123 | last post by:
Hi, I get data from sybase server using ADO Connection and disconnected recordset in my access Database. Now I have a disconnected recordset. I want to insert the contents of this recordset into a Access table. I can loop through the recordset and insert record by record. But I want to do a bulk insert/Update assuming the columns are the same in the recordset and the table. How can I copy a recordset data to a table in one shot? The...
2
2919
by: hotflash | last post by:
Hi Master CroCrew, I found a good PURE ASP that will allow you to upload 10MB file to the server and the file contents such as Network, Author, Title, etc... will insert to MS Access at the same time. Below is a working script that I used. Let's say after the file is uploaded to the server and a record created with the file contents above to the MS Access (using the script below). If I want to UPDATE that record let's say, change the...
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10555
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7607
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2974
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.