K
Keri
Hi I'm using Vba code to filter for stauts, date etc. but the code is not
reconizeing my subform. Its just showing all records.
Here is my code:
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 Property Name
If Not IsNull(Me.Property_Name) Then
'Create Predicate
strWhere = strWhere & " AND " & "Tracking Log.[Property Name] = " &
Me.Property_Name & ""
End If
' If Assigned To
If Not IsNull(Me.Assigned_To) Then
'Create Predicate
strWhere = strWhere & " AND " & "Tracking Log.[Assigned To] = " &
Me.Assigned_To & ""
End If
' If Opened By
If Not IsNull(Me.Opened_By) Then
'Add the predicate
strWhere = strWhere & " AND " & "Tracking Log.[Opened By] = " &
Me.Opened_By & ""
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 Opened Date From
If IsDate(Me.OpenedDateFrom) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Opened Date] >= " &
GetDateFilter(Me.OpenedDateFrom)
ElseIf Nz(Me.OpenedDateFrom) <> "" Then
strError = cInvalidDateError
End If
' If Opened Date To
If IsDate(Me.OpenedDateTo) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Opened Date] <= " &
GetDateFilter(Me.OpenedDateTo)
ElseIf Nz(Me.OpenedDateTo) <> "" 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 - exact
strWhere = strWhere & "AND" & "TrackingLog.Task ='" & Me.Task & ""
End If
If strError <> "" Then
MsgBox strError
Else
'DoCmd.OpenForm "Search Tasks", acFormsDS, ,strWhere,acFormEdit,
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
When I pick a search for any of the above search terms I get an error 2448
cant assign value to to this object. I've read everything I possibley could
to trouble shot this. Any help would help.
Thanks,
Keri
reconizeing my subform. Its just showing all records.
Here is my code:
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 Property Name
If Not IsNull(Me.Property_Name) Then
'Create Predicate
strWhere = strWhere & " AND " & "Tracking Log.[Property Name] = " &
Me.Property_Name & ""
End If
' If Assigned To
If Not IsNull(Me.Assigned_To) Then
'Create Predicate
strWhere = strWhere & " AND " & "Tracking Log.[Assigned To] = " &
Me.Assigned_To & ""
End If
' If Opened By
If Not IsNull(Me.Opened_By) Then
'Add the predicate
strWhere = strWhere & " AND " & "Tracking Log.[Opened By] = " &
Me.Opened_By & ""
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 Opened Date From
If IsDate(Me.OpenedDateFrom) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Opened Date] >= " &
GetDateFilter(Me.OpenedDateFrom)
ElseIf Nz(Me.OpenedDateFrom) <> "" Then
strError = cInvalidDateError
End If
' If Opened Date To
If IsDate(Me.OpenedDateTo) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Tracking Log.[Opened Date] <= " &
GetDateFilter(Me.OpenedDateTo)
ElseIf Nz(Me.OpenedDateTo) <> "" 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 - exact
strWhere = strWhere & "AND" & "TrackingLog.Task ='" & Me.Task & ""
End If
If strError <> "" Then
MsgBox strError
Else
'DoCmd.OpenForm "Search Tasks", acFormsDS, ,strWhere,acFormEdit,
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
When I pick a search for any of the above search terms I get an error 2448
cant assign value to to this object. I've read everything I possibley could
to trouble shot this. Any help would help.
Thanks,
Keri