Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 copy record from table to new table

Author  Topic 

Malte
Starting Member

2 Posts

Posted - 2002-04-16 : 09:42:56
During a web page, site by site, more and more details are added
to one record row into a Table. With arriving of the last data in field 11, the whole record should be automatically transferred to
a new table and at the same time should be deleted from the old tabel.
Any idea how to do this? Many thanks in advance.
Malte

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-04-16 : 20:05:51
What I do is, as the user progresses through the site, I store each record in a pending table.

Once the final stage is reached, I call a procedure which
deletes from the destination table
and, copies from the pending table to the destination as a single transaction

If the user bails out before the final stage is reached, then the old data is not deleted and the partial new data not added.

Do you want to ask more?

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

henrikop
Constraint Violating Yak Guru

280 Posts

Posted - 2002-04-17 : 03:58:43
You r using Access right?
And you want to make a NEW table or do you mean ANOTHER EXISTIMG table in the Access database?

You need to know the ID of the first table (primary key). To add a record to a table you can use.

<%
' con is the connection to the database
' strID is you unique key value from the first table
' The quote (') in the WHERE part is needed when you primary key is a string

' Add record in the 'new' table with data from the first (filled) table
con.execute "INSERT INTO SecondTable (Field2, Field3, Field4) Select Field2, Field3, Field4 FROM FirstTable WHERE ID = '" & strID & "' ;"

' If there wasn't an error the next code should be fired too
con.execute "DELETE FROM FirstTable WHERE ID = '" & strID & "' ;"

%>


This should do the trick. If you don't understand the code, you really need to do some more study, because this is really basic programming...

Hope it helps


Henri

~~~
Guilt is like a bag of bricks. All you gotta do is set it down...
Go to Top of Page
   

- Advertisement -