lookforsmt
Registered User.
- Local time
- Today, 15:11
- Joined
- Dec 26, 2011
- Messages
- 672
HI!
I am trying to list the dates between the start date and end date to avoid typing the dates one by one in the table.
Below is the code i have found and works pretty well in the immediate window.
However i am clueless how to call this function through a form.
My form has start and end date field.
a) The on-click button on form should trigger the code to run and list the between dates in the table, "tblDate"
b) Alternatively i should also be able to call the code through query
I am trying to list the dates between the start date and end date to avoid typing the dates one by one in the table.
Below is the code i have found and works pretty well in the immediate window.
However i am clueless how to call this function through a form.
My form has start and end date field.
a) The on-click button on form should trigger the code to run and list the between dates in the table, "tblDate"
b) Alternatively i should also be able to call the code through query
Code:
Function MakeDates(dtStart As Date, dtEnd As Date) As Long
Dim dt As Date
Dim rs As DAO.Recordset
Set rs = DBEngine(0)(0).OpenRecordset("tblDate")
With rs
For dt = dtStart To dtEnd
.AddNew
!TheDate = dt
.Update
Next
End With
rs.Close
Set rs = Nothing
End Function