Append Rows based on field value

B

Bernie

I would like to have the append query create a fixed number of rows based on
the value from a field value.

For example, field value = 10. I would like my append query to create 10
records.
 
M

Marshall Barton

Bernie said:
I would like to have the append query create a fixed number of rows based on
the value from a field value.

For example, field value = 10. I would like my append query to create 10
records.


You could do that using a VBA procedure and add the rows
through a record set opened on the destination table.

If you want to do it using a query, then create a little
utility table called Numbers with one field named Num.
Populate the table with records containing 1, 2, 3, ... up
to a 100 or whatever.

Then the query could look like:

INSERT INTO destinationtable (f1, f2, ...)
SELECT f1, f2, ...
FROM sourcetable, Numbers
WHERE fx = keyfieldofrecordtoappend
AND Num <= fieldvalue
 
K

KARL DEWEY

Table CountNumber field CountNUM has number from 0 (zero) through your
maximum spread.

INSERT INTO YourTable ( ID, SN )
SELECT [Enter item number] AS Expr1, [Enter Starting Serial #]+[CountNUM] AS
Expr2
FROM CountNumber
WHERE (((CountNumber.CountNUM)<=[Enter qunaity of records]-1));
 

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