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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy a record a number of times 1

Status
Not open for further replies.

techkenny1

Technical User
Jan 23, 2009
182
AU
Hi
I have a requirement to be able to copy a record from 1 table to another table, but for that record to be copied several times into the 2nd table, with the same data.
Is this possible?

Many thanks,

KP
 
sure, just use a loop.

how are you calling the copy:

in a form? or manually through a query, or in a module?

Michael

It's not what you know. It's who's on Tek-Tip's
 
Hi Michael,
Many thanks for your reply,
I have the data on a form. But I am not sure how to create a loop.

MaNY THANKS,

kp
 
this would be the basic code needed for a loop. you will need to change the mydb.execute ("THIS BIT") for your needs.

i have attached my quick db for you to look at.


Dim myDb As Database
Set myDb = CurrentDb()

mynum = 1

Do While mynum < 3

myDb.Execute ("INSERT INTO tbl2 ( fld1, fld2 ) SELECT '" & [Forms]![frm1]![fld1] & "', '" & [Forms]![frm1]![fld2] & "'")
mynum = mynum + 1
Loop



It's not what you know. It's who's on Tek-Tip's
 
 http://www.arcintl.force9.co.uk/db/tek/NewApp.zip

The really important question here is why would you want to insert multiple copies of a single record into a table? This violates normalization and on the face of it makes no sense.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top