I am trying to create a form that will select records by date range. The form contains 2 textboxes, with pop-up calendars to select dates. I managed to come up with this code, however, it's not working. Whenever I run the code, my database just goes blank, as though it's selecting something that is not in the records.
Expand|Select|Wrap|Line Numbers
- Private Sub Command16_Click()
- Dim Task As String
- Dim startDate As Date
- Dim endDate As Date
- startDate = DateValue(Me.Text12)
- endDate = DateValue(Me.Text14)
- Task = "SELECT * FROM Final WHERE Final.Timestamp BETWEEN #" & Format$(startDate, "dd\/mm/yyyy") & "# AND #" & Format$(endDate, "dd\/mm\/yyyy") & "#;"
- Debug.Print Task
- Me.RecordSource = Task
- End Sub