This example assumes that:
- ID, f_date, and Days are unbound text boxes on your form;
- you wish to add records to Table1, which fields named ID and f_date;
- the code is to run when you click a button named cmdAddRecords
- there are actually entries in all 3 boxes.
Private Sub cmdAddRecords_Click()
Dim rs As DAO.Recordset
Dim dt As Date
Dim dtEnd as Date
dtEnd = DateAdd("d", Me.Days - 1, Me.f_date)
Set rs = dbengine(0)(0).OpenRecordset("Table1", _
dbOpenDynaset, dbAppendOnly)
For dt = Me.f_date To dtEnd
rs.AddNew
rs!ID = Me.ID
rs!f_date = dt
rs.Update
Next
rs.Close
Set rs = Nothing
End Sub
That's completely untested, but should give you an example to work from.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Mark" <ma*********@ntlworld.com> wrote in message
news:Vh*************@newsfe5-gui.ntli.net...
What I am trying to achieve is for a user to enter a colleague
identification number into field [ID]. Then they are to add the first date
of holiday into field [f_date]. Finally they are to add the number of days
into an unbound text box [days]. Once a command is fired, I would like to
be able to add records into tbl_holidays. One for each date the person has
recorded.
e.g.
Input form:
ID f_date Days
10089654 16/11/2004 5
records to be added into table after closure of form:
ID booked_hols
10089654 16/11/2004
10089654 17/11/2004
10089654 18/11/2004
10089654 19/11/2004
10089654 20/11/2004
TIA,
Mark