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

How to create N copies of a record, and randomize some data

Status
Not open for further replies.

mbannen

IS-IT--Management
Jan 1, 2004
12
US
GOAL: Enable users to create a user-defined number of copies of record, while randomizing certain data within the new records and appending those records to a table.

I have two tables:
tbl_source
tbl_run

Users enter data into tbl_source via a form (frm_enter_data), which writes the entered data to tbl_source.

After entering data, I want users to enter the number of copies of the record they want (e.g., 10), and to append 10 copies of that record to tbl_run. I also need to randomize certain data (e.g., add a number to last_name and increment that number to make the last name unique).

Sure I can figure out the increment part...not sure how to easily do the record duplication and insert.

Thanks in advance for being smarter than me.

 
Probably the simplest is set up another table called "Integers" with one field "Num" and populate it with integers from 1 to 100 (or whatever value you will not likely exceed.) Then
Code:
INSERT INTO tblRun

Select (T.LastName & Trim$(Str$(I.Num)) As [LastName], ... OtherFields ..., 

From tblSource T, Integers I

Where I.Num <= [Number of Copies]
      AND ... Filters to select which records you want from tblSource ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top