Hello dear experts.
In my frmListOfOrders I have unbound StartDate and EndDate text boxes as well as search buttons for several predefined intervals (btnCurrentMonth, btnLastMonth etc.).
The underlying code for the search sub is:
The code for the buttons is (instance of btnCurrentMonth):
This setting works fine in one machine with Access 2010, but fails in other machine with Access 2013 and produces Run-time error '3075': “syntax error (missing operator) in query expressions '((OrderDate >= #01-Oct-2020# and OrderDate <= #31-Oct-2020#))' with debugging pointing to the line DoCmd.ApplyFilter task.
What might be the catch?
In my frmListOfOrders I have unbound StartDate and EndDate text boxes as well as search buttons for several predefined intervals (btnCurrentMonth, btnLastMonth etc.).
The underlying code for the search sub is:
Code:
Sub Search()
Dim strCriteria, task As String
Me.Refresh
If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "Missing dates interval", vbInformation, "Enter dates interval"
Me.StartDate.SetFocus
Else
strCriteria = "(OrderDate >= #" & Me.StartDate & "# and OrderDate <= #" & Me.EndDate & "#)"
task = "select * from qryListOfOrders where (" & strCriteria & ")"
DoCmd.ApplyFilter task
End If
End Sub
The code for the buttons is (instance of btnCurrentMonth):
Code:
Private Sub btnCurrentMonth_Click()
Me.StartDate = DateSerial(Year(Date), Month(Date), 1)
Me.EndDate = DateSerial(Year(Date), Month(Date) + 1, 0)
Call Search
End Sub
This setting works fine in one machine with Access 2010, but fails in other machine with Access 2013 and produces Run-time error '3075': “syntax error (missing operator) in query expressions '((OrderDate >= #01-Oct-2020# and OrderDate <= #31-Oct-2020#))' with debugging pointing to the line DoCmd.ApplyFilter task.
What might be the catch?