Code to append the current record from a form to a table

M

Mani

I have a table BD and a form IntroData to populate the table and to view the
records. I want to append one record - not all the fields, only five of them
(Field1, Field2,... , Field5) - to another table BD1 with the same structure,
in another database. And thhis action must correspond to a button on the form.
The record that I copy / append has an autonumber field, which is the
primary key, but its value must not be kept (this number will get the new
value that the correspondent field in the second table BD1 has).
The record that I copy / append must be the one that is displayed, at one
moment, by the form IntroData.
 
K

Klatuu

Use an Append query. It is possible to append to a table in a different mdb
that you are not linked to. The only issues you will have is if there is
WorkGroup Security on the other mdb or if it is password protected.

In VBA Help, look at the lower part of the help screen
Select Microsoft Jet SQL Reference
Select Data Manipulation Language
Select SELECT...INTO Statment
Scroll Down to "See Also"
Select IN Clause

It will show examples of how to do this.
 
M

Mani

Dear Klatuu,
Thanks a lot for your answer.
I come back underlying that "The record that I copy / append must be the one
that is displayed, at one moment, by the form IntroData." This is the
difficult thing for me, as a beginner: to tell to the program that I want
one, and only one, record to be added at the end of the second table, not the
entire original database and not all the fields in the record.
More precisely, it seems difficult, in MS Access, to select a record (which
is not the first or the last), for example the record no. 1325. The record is
displayed by the form that I have created, but... how could I copy a few
fields of it at the end of the second table (BD1) with the help of a button?
 
K

Klatuu

You can select which fields you want to append to BD1 in an append query.
You can also select the form's current record by identifying the primary key
of the record by refering to the control on the form bound to the primary key
field of your table. It would be like this:

WHERE TableKeyField = Forms!IntroData!KeyFieldControl

Of course, you will have to change the names to your actual field names.
 
M

Mani

Dear Klatuu,
This is the answer! Thanks a lot. Everything is much simpler when is
explained.
 

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