Insert X records in table based on value from another table

T

TAG

Newbie question: I have a database where we track dispatched with two
tables, one called Slots, the other called Dispatches.
In the slots table there are 2 fields, one called Week (which hold the
Monday date for each week in the year), the other called Available (in
this field we want to manually enter a number that will tell the system
how many dispatches we can do that week). We want to automatically take
the number from the Slots.Available and enter X number of blank records
in the Dispatch table with the monday date.
How can this be done?
Then we will create a form that can be filled in with the balance of
the information.
Thanks
 
J

John Vinson

Newbie question: I have a database where we track dispatched with two
tables, one called Slots, the other called Dispatches.
In the slots table there are 2 fields, one called Week (which hold the
Monday date for each week in the year), the other called Available (in
this field we want to manually enter a number that will tell the system
how many dispatches we can do that week). We want to automatically take
the number from the Slots.Available and enter X number of blank records
in the Dispatch table with the monday date.
How can this be done?
Then we will create a form that can be filled in with the balance of
the information.
Thanks

You can do this with the aid of another auxiliary table. Create a
table named Num with just one field N, with values 0 through the
largest number you'll ever need - be generous, even with 10000 rows
this is a tiny table.

Create an Insert query using both your Slots table and Num, with NO
join line; change it to an Append query, and put a criterion on N of

< [Slots].[Available]

If there are ten slots available, you'll get ten records appended
(with N values 0 through 9).

John W. Vinson[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