G
Guest
Stuck again. If it werent for this site I would be lost. Thanks to all you
MVP's. I have a query that formats a date field to read only the month and
year that looks like this:
Format$([DateOfService],'mmmm yyyy')
The problem is that I have a form with filters on it and it keeps giving me
run-time error 2448, You cant assign a value to this object. I know I have
my datefilter formated incorrectly. Can someone help, here is the code I am
using:
Private Sub Filter_Click()
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "#mmmm yyyy#"
If Not IsNull(Me.DatabaseFilter) Then
strWhere = strWhere & "([DataBase]=""" & Me.DatabaseFilter & """) AND "
End If
If Not IsNull(Me.LocationFilter) Then
strWhere = strWhere & "([LocationCode]=" & Me.LocationFilter & ") AND "
End If
If Not IsNull(Me.DateByMonthFilter) Then
strWhere = strWhere & "([Date Of Service By Month]=" &
Format(Me.DateByMonthFilter, conJetDate) & ") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "Please enter information into at least one field before
clicking the filter button.", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)
Debug.Print strWhere
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
MVP's. I have a query that formats a date field to read only the month and
year that looks like this:
Format$([DateOfService],'mmmm yyyy')
The problem is that I have a form with filters on it and it keeps giving me
run-time error 2448, You cant assign a value to this object. I know I have
my datefilter formated incorrectly. Can someone help, here is the code I am
using:
Private Sub Filter_Click()
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "#mmmm yyyy#"
If Not IsNull(Me.DatabaseFilter) Then
strWhere = strWhere & "([DataBase]=""" & Me.DatabaseFilter & """) AND "
End If
If Not IsNull(Me.LocationFilter) Then
strWhere = strWhere & "([LocationCode]=" & Me.LocationFilter & ") AND "
End If
If Not IsNull(Me.DateByMonthFilter) Then
strWhere = strWhere & "([Date Of Service By Month]=" &
Format(Me.DateByMonthFilter, conJetDate) & ") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "Please enter information into at least one field before
clicking the filter button.", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)
Debug.Print strWhere
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub