Selecting records in a form for adding to another table

M

Mike

I would like to make a query-based continious form the
purpose of which will be selecting records for adding to
another table.

It should work approximately like as follows:
_______________________
Continious Form

Record 1 [Button]
Record 2 [Button]
Record 3 [Button]
_______________________

When one presses the button on the right of the record,
the record is being added to a destination table.

Please, give me a hint how I can do that?
 
M

Marshall Barton

Mike said:
I would like to make a query-based continious form the
purpose of which will be selecting records for adding to
another table.

It should work approximately like as follows:
_______________________
Continious Form

Record 1 [Button]
Record 2 [Button]
Record 3 [Button]
_______________________

When one presses the button on the right of the record,
the record is being added to a destination table.

The code behind the button could look something like:

Dim db As DAO.Database
Dim strSQL As String
strSQL = "INSERT INTO destination " _
& "SELECT * FROM source " _
& "WHERE keyfield = " & txtkeyfield
Set db = CurrentDb()
db.Execute strSQL, dbFailOnError
Set db = Nothing

But, it's usually a bad idea to copy entire records. Most
situations (archiving the records being an obvious
exception) only need to store the primary key of the source
table record in the destination table.

You may have additional issues if anyone tries to perform
this operation more than once.
 

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