Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create new record from fields of existing record

Status
Not open for further replies.

boysrus

Programmer
Jul 9, 2001
12
0
0
US
Hi,

I would like to write code that copies all of the fields from one record, changes the key, and adds it in as a new record. The key for the 1st record is supplied by the user. The new key is an autonumber field. Would I use recordsets? If so, can you tell me how to do it? Or should I use a query?



 
You would use an Insert query to do this.

try something like this:

Insert Into YourTable (Col1, Col2, COl3...)
Select OldCol1, OldCol2, OldCol3...
From YourTable

Think will copy all the rows from the table an insert them back into the table. Leave out the column that is the autonumber and make sure the Select column names are in the same order as in the Insert column names.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top