K
Keri
Hi I have modified a microsoft template to track our office mail. I am
having problems with a code. I have a search form. I keep getting the error
2448 Cant assign any value. When I go to debug the code the last to lines
keep highlighting yellow. its using the string strwhere. Here is the code its
the very last two lines I having problems with.
Private Sub Search_Click()
Const cInvalidDateError As String = "You have entered an invalid date."
Dim strWhere As String
Dim strError As String
strWhere = "1=1"
' If Assigned To
If Not IsNull(Me.AssignedTo) Then
'Create Predicate
strWhere = strWhere & " AND " & "Tracking Log.[Assigned To] = " &
Me.AssignedTo & ""
End If
' If Opened By
If Not IsNull(Me.OpenedBy) Then
'Add the predicate
strWhere = strWhere & " AND " & "Tracking Log.[Opened By] = " &
Me.OpenedBy & ""
End If
' If Status
If Nz(Me.Status) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "Tracking Log.Status = '" &
Me.Status & "'"
End If
' If Open Date From
If IsDate(Me.OpenDateFrom) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Open Date] >= " &
GetDateFilter(Me.OpenDateFrom)
ElseIf Nz(Me.OpenDateFrom) <> "" Then
strError = cInvalidDateError
End If
' If Open Date To
If IsDate(Me.OpenDateTo) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Open Date] <= " &
GetDateFilter(Me.OpenDateTo)
ElseIf Nz(Me.OpenDateTo) <> "" Then
strError = cInvalidDateError
End If
' If Due Date From
If IsDate(Me.DueDateFrom) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Due Date] >= " &
GetDateFilter(Me.DueDateFrom)
ElseIf Nz(Me.DueDateFrom) <> "" Then
strError = cInvalidDateError
End If
' If Due Date To
If IsDate(Me.DueDateTo) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Due Date] <= " &
GetDateFilter(Me.DueDateTo)
ElseIf Nz(Me.DueDateTo) <> "" Then
strError = cInvalidDateError
End If
' If Task
If Nz(Me.Task) <> "" Then
' Add it to the predicate - match on leading characters
strWhere = strWhere & " AND " & "Tracking Log.Task Like '*" &
Me.Task & "*'"
End If
If strError <> "" Then
MsgBox strError
Else
'DoCmd.OpenForm "Browse All Tasks", acFormDS, acFormEdit,
strWhere,acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.Browse_All_Tasks.Form.Filter = strWhere
Me.Browse_All_Tasks.Form.FilterOn = True
End If
End Sub
Any help or suggestions would be very helpful. I've google the problem but
I cannot seem to fix it. Thanks for looking at this
Keri
having problems with a code. I have a search form. I keep getting the error
2448 Cant assign any value. When I go to debug the code the last to lines
keep highlighting yellow. its using the string strwhere. Here is the code its
the very last two lines I having problems with.
Private Sub Search_Click()
Const cInvalidDateError As String = "You have entered an invalid date."
Dim strWhere As String
Dim strError As String
strWhere = "1=1"
' If Assigned To
If Not IsNull(Me.AssignedTo) Then
'Create Predicate
strWhere = strWhere & " AND " & "Tracking Log.[Assigned To] = " &
Me.AssignedTo & ""
End If
' If Opened By
If Not IsNull(Me.OpenedBy) Then
'Add the predicate
strWhere = strWhere & " AND " & "Tracking Log.[Opened By] = " &
Me.OpenedBy & ""
End If
' If Status
If Nz(Me.Status) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "Tracking Log.Status = '" &
Me.Status & "'"
End If
' If Open Date From
If IsDate(Me.OpenDateFrom) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Open Date] >= " &
GetDateFilter(Me.OpenDateFrom)
ElseIf Nz(Me.OpenDateFrom) <> "" Then
strError = cInvalidDateError
End If
' If Open Date To
If IsDate(Me.OpenDateTo) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Open Date] <= " &
GetDateFilter(Me.OpenDateTo)
ElseIf Nz(Me.OpenDateTo) <> "" Then
strError = cInvalidDateError
End If
' If Due Date From
If IsDate(Me.DueDateFrom) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Due Date] >= " &
GetDateFilter(Me.DueDateFrom)
ElseIf Nz(Me.DueDateFrom) <> "" Then
strError = cInvalidDateError
End If
' If Due Date To
If IsDate(Me.DueDateTo) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Due Date] <= " &
GetDateFilter(Me.DueDateTo)
ElseIf Nz(Me.DueDateTo) <> "" Then
strError = cInvalidDateError
End If
' If Task
If Nz(Me.Task) <> "" Then
' Add it to the predicate - match on leading characters
strWhere = strWhere & " AND " & "Tracking Log.Task Like '*" &
Me.Task & "*'"
End If
If strError <> "" Then
MsgBox strError
Else
'DoCmd.OpenForm "Browse All Tasks", acFormDS, acFormEdit,
strWhere,acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.Browse_All_Tasks.Form.Filter = strWhere
Me.Browse_All_Tasks.Form.FilterOn = True
End If
End Sub
Any help or suggestions would be very helpful. I've google the problem but
I cannot seem to fix it. Thanks for looking at this
Keri