I have several ranges of dates (2007-03-15 - 2007-03-21, format YYYY,MM,DD) and I need to list all of the dates in the range and not sure how to do this. I wrote an OnLoad procedure that should run each time the form is opened. I want the procedure to insert the dates between the range into the the table 'travel_dates" for each trip with the authorization number being the linking number. I keep getting Runtime error 3061. Am I way off base? Any thoughts would be helpful!
Thanks,
Jen
--------
Private Sub Form_Load()
Dim Datecount As Integer 'count down number
Dim Departday As Date 'last day of private
Dim IntervalDay As String 'interval in days to add to the date
Dim ALdate As Date 'new date calculated
Dim TANo As String 'travel authorization number
Dim dbs As Database
Set dbs = CurrentDb
IntervalDay = "d" 'set the interval
Datecount = Me.NumberOfNights 'set number of nights credited to private
ALdate = Me.ArrivalDate 'set first private date
TANo = Me.[2004_private.TA Number]
Do While Datecount <> 0
dbs.Execute "INSERT INTO travel_dates (date_day, date_ta_no) VALUES (ALdate, TANo);" 'insert new dates
ALdate = DateAdd(IntervalDay, 1, ALdate) 'calculate the date on private
Datecount = Datecount - 1
Loop
dbs.Close
End Sub