473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Make local copy of backend table - how?

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=Y es"

Dim rec As ADODB.Recordset
Set rec = New ADODB.Recordset

Dim theSQLString
theSQLString = "Select * From backEndTable"

rec.Open theSQLString, theConnectionString, adOpenStatic,
adLockOptimistic

Do Until rec.EOF
' copy each record to the frontEndTable, field by field
rec.MoveNext
Loop

This will work but I want to be able to copy from the back end to the
front end in a simpler way. Either some SQL on the backend which can
copy directly to the frontend; but I do not know how to specify the
frontend table in a way that the backend understands.

Alternatively, having got the recordset, I would like to copy all of it
to the frontend table in a single statement without having to loop
through the records. Something like "copy the recordset 'rec' to
the table 'frontEndTable'"

Are either of these possible? If so, how?

Dec 14 '06 #1
4 4953
Link the SQL Server table.

Create a Make Table query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jim Devenish" <in***************@foobox.comwrote in message
news:11*********************@n67g2000cwd.googlegro ups.com...
>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=Y es"

Dim rec As ADODB.Recordset
Set rec = New ADODB.Recordset

Dim theSQLString
theSQLString = "Select * From backEndTable"

rec.Open theSQLString, theConnectionString, adOpenStatic,
adLockOptimistic

Do Until rec.EOF
' copy each record to the frontEndTable, field by field
rec.MoveNext
Loop

This will work but I want to be able to copy from the back end to the
front end in a simpler way. Either some SQL on the backend which can
copy directly to the frontend; but I do not know how to specify the
frontend table in a way that the backend understands.

Alternatively, having got the recordset, I would like to copy all of it
to the frontend table in a single statement without having to loop
through the records. Something like "copy the recordset 'rec' to
the table 'frontEndTable'"

Are either of these possible? If so, how?

Dec 14 '06 #2
"Jim Devenish" <in***************@foobox.comwrote in message
news:11*********************@n67g2000cwd.googlegro ups.com...
>I wish to copy a table on a SQL Server backend to a table on an Access
(.mdb) front end in the simplest way.
Alternatively, having got the recordset, I would like to copy all of it
to the frontend table in a single statement without having to loop
through the records. Something like "copy the recordset 'rec' to
the table 'frontEndTable'"

Are either of these possible? If so, how?
How about a make-table query? Or am I missing the point?

Keith.
www.keithwilby.com
Dec 14 '06 #3
Jim Devenish wrote:
I wish to copy a table on a SQL Server backend to a table on an Access
(.mdb) front end in the simplest way.
Older ways include:

Create a sister ADP file connected to the SQL db. Then (from the MDB):
DoCmd.TransferDatabase acImport, "Microsoft Access", _
ADPFile, acTable, TABLE_NAME, TABLE_NAME, False
-
Create an ODBC link: Then
DoCmd.TransferDatabase acLink, "ODBC Database", _
"ODBC;DSN=DataSource1;UID=User2;PWD=www;LANGUAGE=u s_english;" _
& "DATABASE=pubs", acTable, "Authors", "dboAuthors"
-
Create a specific non-DSN odbc link to the table:
Sub adub()

Dim connect$
Dim tdf As DAO.TableDef
Dim db As DAO.Database

strConnect = "ODBC;DRIVER={SQL Server}" _
& ";SERVER=__________" _
& ";DATABASE=__________" _
& ";UID=__________" _
& ";PWD=__________"

Set db = CurrentDb()
Set tdf = db.CreateTableDef("LocalFFDBAAccounts")
tdf.SourceTableName = "FFDBAAccounts"

tdf.connect = connect

db.TableDefs.Append tdf
db.TableDefs.Refresh

End Sub

Then use the table or just copy it and then remove the link.

--
.... there may be newer ways; if there are we can hope someone will tell
us.

Dec 14 '06 #4
I was trying to do it without linking to the backend table. Since I
can access the backend table without a link, I was hoping to make a
copy as well.

But thanks anyway. I will try it with a link

Jim

Allen Browne wrote:
Link the SQL Server table.

Create a Make Table query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jim Devenish" <in***************@foobox.comwrote in message
news:11*********************@n67g2000cwd.googlegro ups.com...
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=Y es"

Dim rec As ADODB.Recordset
Set rec = New ADODB.Recordset

Dim theSQLString
theSQLString = "Select * From backEndTable"

rec.Open theSQLString, theConnectionString, adOpenStatic,
adLockOptimistic

Do Until rec.EOF
' copy each record to the frontEndTable, field by field
rec.MoveNext
Loop

This will work but I want to be able to copy from the back end to the
front end in a simpler way. Either some SQL on the backend which can
copy directly to the frontend; but I do not know how to specify the
frontend table in a way that the backend understands.

Alternatively, having got the recordset, I would like to copy all of it
to the frontend table in a single statement without having to loop
through the records. Something like "copy the recordset 'rec' to
the table 'frontEndTable'"

Are either of these possible? If so, how?
Dec 14 '06 #5

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

Similar topics

6
by: MAB71 | last post by:
There should be a way to copy an access database ( .mdb file ) without closing connections to it. Unfortunately the FileCopy statement in VB gives an error if users are connected to the db. But I...
7
by: nydiroth | last post by:
Our servers went down for over 6 hours yesterday and I was asked if there was a way to store the database on the server and a local station at the same time. My datbase is split and the tables...
1
by: Knepper, Michelle | last post by:
Hi out there, I'm a first-time user of the "Copy ... From..." command, and I'm trying to load a table from a text flat file. http://www.postgresql.org/docs/7.4/static/sql-copy.html I don't...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
3
by: LurfysMa | last post by:
I would like to hear opinions on the tradeoffs of putting the tables, forms, and queries for several related datasets in separate databases vs one combined database. I am working on an...
10
by: Jim Devenish | last post by:
I have a split front end/back end system. However I create a number of local tables to carry out certain operations. There is a tendency for the front end to bloat so I have set 'compact on...
0
by: M Cavanagh | last post by:
I am fairly new using functions to return file info and I made an assumption that a function working on a local machine would work fine on a server. I have searched several Access books to find a...
7
by: ShyGuy | last post by:
Is ther a way to copy a table, from the backend of a split database, into a database on another machine from the front end?
3
by: salad | last post by:
I have an A97 application that is NOT split on a network. It is used by 15+ folks continually. It is quick and fast. I split it several years ago and had to merge it together again after the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.