Transfer of specific fields of one data base to another

B

Bob B

I would like to trasfer some fields, name, soc sec no, age,etc from a open
record in one access data base to create a new record in another access data
base. How can I accomplish this?
 
K

Ken Sheridan

Assuming that by 'another database' you mean a separate file, not another
table in the current database, then create a link to the table in the other
database (File | Get External Data | Link Tables on the main database menu
bar, or equivalent if using Access 2007). Then from your form, e.g. via a
command button you can execute an SQL statement to insert a row into the
linked table, e.g.

Dim cmd As ADODB.Command
Dim strSQL As String

Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText

' ensure current record is saved
Me.Dirty = False

' insert row into linked table
strSQL = "INSERT INTO [table2]([name], [soc sec no], [age]) " & _
"SELECT [name], [soc sec no], [age] " & _
"FROM [table1] " & _
"WHERE MyID = " & Me.MyID

cmd.CommandText = strSQL
cmd.Execute

where table2 is the linked table, table1 is the form's underlying table and
MyID is its primary key column of number data type, e.g. an autonumber.

However, duplicating data like this is not usually a good idea as it can
allow anomalies to creep in. If, instead of having a local table in the
other database you simply have a link to your current table, then whatever
changes you make to the data in the current table will automatically show in
the linked table in the other database.

Ken Sheridan
Stafford, England
 
T

Troy

You can link to a table in the other database.

That table will then show in your database.

Then create an append query. Select the table your data is coming from and
the table it is going to (your linked table)

You would need to set criteria to send so many records depending on what
your condition is. If you are doing this from a form your could grab the ID
of the record and use that as your criteria =forms!Formname!NameofIDField

Run the query

Access will say it is about to append x rows to your table.

You could also run this from a macro
 
A

a a r o n . k e m p f

Correction!

Linked tables _ALWAYS_ lead to performance problems and unnecessary
complexity.

With linked tables, you have a endless rabbit hole of 'oh, but did you
set the connecton string on the Sql Passthrough queries'
and 'needing to reinvent the wheel to call a sproc'

It is best to keep your logic in a database format that has a future.
Like SQL Server for example.

Jet and Linked Tables isn't the best platform for SQL Server
databases.

Access Data Projects have a fantastic future-- the format (SQL Server)
is used all over the world.
SQL Server has something like _TWICE_ as many seats / processor
licenses as Oracle.

-Aaron


Assuming that by 'another database' you mean a separate file, not another
table in the current database, then create a link to the table in the other
database (File | Get External Data | Link  Tables on the main database menu
bar, or equivalent if using Access 2007).  Then from your form, e.g. via a
command button you can execute an SQL statement to insert a row into the
linked table, e.g.

    Dim cmd As ADODB.Command
    Dim strSQL As String

    Set cmd = New ADODB.Command
    cmd.ActiveConnection = CurrentProject.Connection
    cmd.CommandType = adCmdText

    ' ensure current record is saved
    Me.Dirty = False

    ' insert row into linked table
    strSQL = "INSERT INTO [table2]([name], [soc sec no], [age]) " &_
        "SELECT [name], [soc sec no], [age] " & _
        "FROM [table1] " & _
        "WHERE MyID = " & Me.MyID

        cmd.CommandText = strSQL
        cmd.Execute

where table2 is the linked table, table1 is the form's underlying table and
MyID is its primary key column of number data type, e.g. an autonumber.

However, duplicating data like this is not usually a good idea as it can
allow anomalies to creep in.  If, instead of having a local table in the
other database you simply have a link to your current table, then whatever
changes you make to the data in the current table will automatically showin
the linked table in the other database.

Ken Sheridan
Stafford, England



Bob B said:
I would like to trasfer some fields, name, soc sec no, age,etc from a open
record in one access data base to create a new record in another accessdata
base.  How can I accomplish this?- Hide quoted text -

- Show quoted text -
 
A

a a r o n . k e m p f

Tony;

I am not wrong.

You sit around and get corruption like once amonth-- and you think
that it's acceptable.

I say that it is not.

You can't blame it on the network-- you don't need Citrix to run MS
Access
You just need to use a real database backend, kid.

WAN, LAN, VPN, Wireless-- SQL Server works great over all of those
networks, and Jet doesn't work over any of them (without you guys
blaming everything and anything on the network)

-Aaron
 
A

a a r o n . k e m p f

-----------------------------------------------------------------------------------------------------------------------------------------------------------
"Microsoft Jet is a file-sharing database system. A file-sharing
database is one in which all the processing of the file
takes place at the client. When a file-sharing database, such as
Microsoft Jet, is used in a multiuser environment,
multiple client processes are using file read, write, and locking
operations on the same shared file across a network. If,
for any reason, a process cannot be completed, the file can be left in
an incomplete or a corrupted state. Two
examples of when a process may not be completed is when a client is
terminated unexpectedly or when a network
connection to a server is dropped.

Microsoft Jet is not intended to be used with high-stress, high-
concurrency, 24x7 server applications, such as Web,
commerce, transactional, and messaging servers. For these type of
applications, the best solution is to switch to a true
client/server-based database system such as Microsoft Data Engine
(MSDE) or Microsoft SQL Server. When you use
Microsoft Jet in high-stress applications such as Microsoft Internet
Information Server (IIS), customers have reported
database corruption, stability issues such as IIS crashing or locking
up, and also a sudden and persistent failure of the
driver to connect to a valid database that requires re-starting the
IIS service."
 
G

Gina Whipp

The title to which Aaron refers to is:

How to keep a Jet 4.0 database in top working condition in Access 2000

Link: http://support.microsoft.com/kb/300216

Maybe you could find something more recent and pertinent?


--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II
message
-----------------------------------------------------------------------------------------------------------------------------------------------------------
"Microsoft Jet is a file-sharing database system. A file-sharing
database is one in which all the processing of the file
takes place at the client. When a file-sharing database, such as
Microsoft Jet, is used in a multiuser environment,
multiple client processes are using file read, write, and locking
operations on the same shared file across a network. If,
for any reason, a process cannot be completed, the file can be left in
an incomplete or a corrupted state. Two
examples of when a process may not be completed is when a client is
terminated unexpectedly or when a network
connection to a server is dropped.

Microsoft Jet is not intended to be used with high-stress, high-
concurrency, 24x7 server applications, such as Web,
commerce, transactional, and messaging servers. For these type of
applications, the best solution is to switch to a true
client/server-based database system such as Microsoft Data Engine
(MSDE) or Microsoft SQL Server. When you use
Microsoft Jet in high-stress applications such as Microsoft Internet
Information Server (IIS), customers have reported
database corruption, stability issues such as IIS crashing or locking
up, and also a sudden and persistent failure of the
driver to connect to a valid database that requires re-starting the
IIS service."
 
T

Tony Toews [MVP]

a a r o n . k e m p f @ g m a i l . c o m said:
You sit around and get corruption like once amonth-- and you think
that it's acceptable.

Wrong. Last time any of my clients had any corruption was, ummm, ahhh, I gotta
think real hard hard. Four years ago or so. Something like that anyhow.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
B

Bob B

This is my coding:
Private Sub Command39_Click()
Dim cmd As ADODB.Command
Dim strSQL As String
Set cmd = New ADODB.Command
cmd.AtiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText
' ensure current record is saved
Me.Dirty = False
'insert row from linked table
strSQL = "INSERT INTO {HRPD_be.mdb}({SSN}, {LastName}, {FirstName}, {Age})"
& _
"SELECT{Social Security #}, {Last Name}, {First Name}, {Age}" & _
"FROM {Clients_be.mdb}" & _
"WHERE MyId = " & Me.MyID

cmd.CommandText strSQL
cmd.Execute

End Sub

I get a error: "user defind tupe not defined" at STM: cmd.AtiveConnection =
CurrentProject.Connection

Ken Sheridan said:
Assuming that by 'another database' you mean a separate file, not another
table in the current database, then create a link to the table in the other
database (File | Get External Data | Link Tables on the main database menu
bar, or equivalent if using Access 2007). Then from your form, e.g. via a
command button you can execute an SQL statement to insert a row into the
linked table, e.g.

Dim cmd As ADODB.Command
Dim strSQL As String

Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText

' ensure current record is saved
Me.Dirty = False

' insert row into linked table
strSQL = "INSERT INTO [table2]([name], [soc sec no], [age]) " & _
"SELECT [name], [soc sec no], [age] " & _
"FROM [table1] " & _
"WHERE MyID = " & Me.MyID

cmd.CommandText = strSQL
cmd.Execute

where table2 is the linked table, table1 is the form's underlying table and
MyID is its primary key column of number data type, e.g. an autonumber.

However, duplicating data like this is not usually a good idea as it can
allow anomalies to creep in. If, instead of having a local table in the
other database you simply have a link to your current table, then whatever
changes you make to the data in the current table will automatically show in
the linked table in the other database.

Ken Sheridan
Stafford, England

Bob B said:
I would like to trasfer some fields, name, soc sec no, age,etc from a open
record in one access data base to create a new record in another access data
base. How can I accomplish this?
 
D

Douglas J. Steele

That should be

Set cmd.ActiveConnection = CurrentProject.Connection

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bob B said:
This is my coding:
Private Sub Command39_Click()
Dim cmd As ADODB.Command
Dim strSQL As String
Set cmd = New ADODB.Command
cmd.AtiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText
' ensure current record is saved
Me.Dirty = False
'insert row from linked table
strSQL = "INSERT INTO {HRPD_be.mdb}({SSN}, {LastName}, {FirstName},
{Age})"
& _
"SELECT{Social Security #}, {Last Name}, {First Name}, {Age}" & _
"FROM {Clients_be.mdb}" & _
"WHERE MyId = " & Me.MyID

cmd.CommandText strSQL
cmd.Execute

End Sub

I get a error: "user defind tupe not defined" at STM: cmd.AtiveConnection
=
CurrentProject.Connection

Ken Sheridan said:
Assuming that by 'another database' you mean a separate file, not another
table in the current database, then create a link to the table in the
other
database (File | Get External Data | Link Tables on the main database
menu
bar, or equivalent if using Access 2007). Then from your form, e.g. via
a
command button you can execute an SQL statement to insert a row into the
linked table, e.g.

Dim cmd As ADODB.Command
Dim strSQL As String

Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText

' ensure current record is saved
Me.Dirty = False

' insert row into linked table
strSQL = "INSERT INTO [table2]([name], [soc sec no], [age]) " & _
"SELECT [name], [soc sec no], [age] " & _
"FROM [table1] " & _
"WHERE MyID = " & Me.MyID

cmd.CommandText = strSQL
cmd.Execute

where table2 is the linked table, table1 is the form's underlying table
and
MyID is its primary key column of number data type, e.g. an autonumber.

However, duplicating data like this is not usually a good idea as it can
allow anomalies to creep in. If, instead of having a local table in the
other database you simply have a link to your current table, then
whatever
changes you make to the data in the current table will automatically show
in
the linked table in the other database.

Ken Sheridan
Stafford, England

Bob B said:
I would like to trasfer some fields, name, soc sec no, age,etc from a
open
record in one access data base to create a new record in another access
data
base. How can I accomplish this?
 
A

a a r o n . k e m p f

good for you. I don't believe you though. I've been called in by 20
different companies to fix the Jet corruption problem, and the answer
is SQL Server.

Maybe you should stop forcing your customers to buy Citrix.
Maybe you should allow your customers to use your Access applications
over Wan, Wireless, VPN, etc


Again-- so sorry that you had such a hard trouble on the one
conversion you attempted... Maybe you should try to learn the worlds
most popular database, if you had trouble upsizing a simple Jet
database.

But your trouble-- because you're not smart enough-- doesn't mandate
that everyone everywhere needs to use Jet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top