Or an even quicker way to fill the list box
This sub won't work as it stands, you will probably have to make some alterations to make it work exactly right, but it should give you a general idea.
n.b Make sure the record set is ordered by the date.Code:Private Sub fillListBoxWithDates() Dim i As Integer, iLoopLen As Integer Dim dtStart As Date, dtEnd As Date rs.movefirst 'firstdate is the date that would go in the 'list box if it was available dtStart = firstdate Do Until rs.EOF 'get the date of this record dtEnd = rs!Date 'now you want to loop for the number of dates 'between the first date and the date in this record 'and fill them into the list box iLoopLen = DateDiff("d", dtStart, dtEnd) For i = 1 To iLoopLen 'may need -1 List1.AddItem DateAdd("d", i, dtStart) 'add dates Next i 'set the loop start to the date after the 'date in the record dtStart = DateAdd("d", 1, dtEnd) rs.movenext Loop 'if the loop start date is less than the lastdate 'then you want to fill the list box with the rest 'of the dates. 'lastdate is the last available date for the room 'to be booked for, say a year ahead of the firstdate iLoopLen = DateDiff("d", dtStart, lastdate) For i = 1 To iLoopLen List1.AddItem DateAdd("d", i, dtStart) Next i End Sub




Reply With Quote