Insert records in table based on number in another table

G

Guest

Is this possible:

I have 2 tables: Schedule and Monday

Monday has the fields called
Monday (date field and primary key)
Slots (number)

Schedule has the fields:
Schedule ID (auto number and primary key)
Monday (date field)
Customer

What I want to do is put a number in the Monday.slots field and then have
this table insert X # of records into the Schedule table with the monday date

Example
Monday table has the following record
Monday.Monday = 02/19/07
Monday.slots = 8
In the schedule table I want to see 8 records with 02/19/07 in the
Schedule.Monday field.
 
M

Michel Walsh

You can, but you need a 'driver' table. My favorite goes by the name of
Iotas, have one field, iota, its primary key, with valued from 0 to 999.

SELECT a.*, b.iota
FROM myTable As a INNER JOIN iotas As b ON b.iota < a.quantity



If the values, in iotas, run from 1 to 1000 instead, use ON b.iota <=
a.quantity


To create the table Iotas, you can create the sequence in Excel, and import
the data, or create a table Ds, one column, d, with values from 0 to 9 and
then:

SELECT a.d+10*b.d +100*c.d
FROM Ds As a, Ds AS b, Ds AS c


also generate the 1000 values (one per record).



Hoping it may help,
Vanderghast, Access MVP
 

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