Hello All,
I had a request from my boss to add time to out date field - "tTaskDueDate"
I have changed default value from Date() to Now() in the form.
I had this code working fine until now:
Then the query stopped working properly, doesn't bring up records with date or with date and time, doesn't give any errors either.
I've done some searching and found about FORMAT.
I managed to make the YESTERDAY, TODAY and TOMORROW work, but can't work out anything after that, gives my runtime error 3464 data type mismatch, I obviously didn't format something correctly. I believe the WEEKDAY part.
my new code looks like this:
I would greatly appreciate any help.
Many thanks
I had a request from my boss to add time to out date field - "tTaskDueDate"
I have changed default value from Date() to Now() in the form.
I had this code working fine until now:
Code:
Select Case Me.cboAPduedate
Case 1
strWhere = strWhere & "tTaskDueDate = date()-1 And " 'Yesterday
Case 2
strWhere = strWhere & "tTaskDueDate <= date() AND " 'Today and older
Case 3
strWhere = strWhere & "tTaskDueDate = date()+1 AND " 'Tomorrow
Case 4
strWhere = strWhere & "tTaskDueDate = date() + 7 - Weekday(Date())+2 AND " 'next Monday
Case 5
strWhere = strWhere & "tTaskDueDate = date() + 7 - Weekday(Date())+3 AND " 'next Tuesday
Case 6
strWhere = strWhere & "tTaskDueDate = date() + 7 - Weekday(Date())+4 AND " 'next Wednesday
Case 7
strWhere = strWhere & "tTaskDueDate = date() + 7 - Weekday(Date())+5 AND " 'next Thursday
Case 8
strWhere = strWhere & "tTaskDueDate = date() + 7 - Weekday(Date())+6 AND " 'next Friday
Case 9
strWhere = strWhere & "tTaskDueDate = date() + 7 - Weekday(Date()) AND " 'next Saturday
Case 10
strWhere = strWhere & "tTaskDueDate = date() + 7 - Weekday(Date())+1 AND " 'next Sunday
Case 11
strWhere = strWhere & "tTaskDueDate >= date() + 7 - Weekday(Date())+2 and tTaskDueDate <= date() + 7 - Weekday(Date())+7 AND " 'Next week
End Select
Then the query stopped working properly, doesn't bring up records with date or with date and time, doesn't give any errors either.
I've done some searching and found about FORMAT.
Code:
Format([tTaskDueDate],'yyyy-mm-dd')
I managed to make the YESTERDAY, TODAY and TOMORROW work, but can't work out anything after that, gives my runtime error 3464 data type mismatch, I obviously didn't format something correctly. I believe the WEEKDAY part.
my new code looks like this:
Code:
Select Case Me.cboAPduedate
Case 1
strWhere = strWhere & "Format([tTaskDueDate],'yyyy-mm-dd') = Format(Date()-1, 'yyyy-mm-dd') AND " 'Yesterday
Case 2
strWhere = strWhere & "Format([tTaskDueDate],'yyyy-mm-dd') <= Format(Date(), 'yyyy-mm-dd') AND " 'Today and older
Case 3
strWhere = strWhere & "Format([tTaskDueDate],'yyyy-mm-dd') = Format(Date()+1, 'yyyy-mm-dd') AND " 'Tomorrow
Case 4
strWhere = strWhere & "Format([tTaskDueDate],'yyyy-mm-dd') = Format(Date()+7, 'yyyy-mm-dd') - Weekday(date()+2) AND " 'next Monday
Case 5
strWhere = strWhere & "Format([tTaskDueDate],'yyyy-mm-dd') = date() + 7 - Weekday(Date())+3 AND " 'next Tuesday
Case 6
strWhere = strWhere & "Format([tTaskDueDate],'yyyy-mm-dd') = date() + 7 - Weekday(Date())+4 AND " 'next Wednesday
Case 7
strWhere = strWhere & "Format([tTaskDueDate],'yyyy-mm-dd') = date() + 7 - Weekday(Date())+5 AND " 'next Thursday
Case 8
strWhere = strWhere & "Format([tTaskDueDate],'yyyy-mm-dd') = date() + 7 - Weekday(Date())+6 AND " 'next Friday
Case 9
strWhere = strWhere & "Format([tTaskDueDate],'yyyy-mm-dd') = date() + 7 - Weekday(Date()) AND " 'next Saturday
Case 10
strWhere = strWhere & "Format([tTaskDueDate],'yyyy-mm-dd') = date() + 7 - Weekday(Date())+1 AND " 'next Sunday
Case 11
strWhere = strWhere & "Format([tTaskDueDate],'yyyy-mm-dd') >= date() + 7 - Weekday(Date())+2 and tTaskDueDate <= date() + 7 - Weekday(Date())+7 AND " 'Next week
End Select
I would greatly appreciate any help.
Many thanks