The dates range from the 1st to 9th do not filter in to the report but if I set the date from the 31st to 10th then they do.
Do you know why this happens?
If I hard code the query or use a parameter it filters fine.
I have tried changing the variables to strings, CDATE, DATEVALUE, format etc. am i missing something out ?
They all do the same
This is the code that runs
Expand|Select|Wrap|Line Numbers
- Sub TxtFinishDate_Exit()
- TxtDateStart = [Form_Frm Choose What To Print].TxtStartDate.Value
- TxtDateEnd = [Form_Frm Choose What To Print].TxtFinishDate.Value
- MYWhereCondition = "[Delivery_Date] Between #" & TxtDateStart & "# And #" & TxtDateEnd & "#"
- 'this is an alternate line of code
- 'MYWhereCondition = "[Delivery_Date] Between " & Format(TxtDateStart, "\#dd/m/yyyy hh:mm\#") & " And " & Format(TxtDateEnd, "\#dd/m/yyyy hh:mm#")
- ' this code is for checking string oputputs in the imediate window
- Debug.Print "From Sub TxtFinishDate_Exit :" & "[Delivery_Date] Between " & Format(TxtDateStart, "\#dd/m/yyyy hh:mm\#") & " And " & Format(TxtDateEnd, "\#dd/m/yyyy hh:mm\#")
- Debug.Print "From Sub TxtFinishDate_Exit :" & MYWhereCondition
- If Not (IsNull(TxtDateStart) Or IsNull(TxtDateEnd)) Then
- DoCmd.OpenReport "Rpt Access Export Without Matching Definitions by date range1", acViewPreview, WhereCondition:=MYWhereCondition
- Else
- MsgBox "You must specify both dates before opening the report"
- End If
- End Sub