Problem with Runtime Error 2448

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
 
T

Tom van Stiphout

On Tue, 14 Oct 2008 12:19:01 -0700, Keri

So you run DoCmd.OpenForm "Browse All Tasks"
First off, change that name to a single word. frmBrowseAllTasks comes
to mind.
The syntax "Me.Browse_All_Tasks.Form" is only used to refer to a
subform on "Me" named "Browse_All_Tasks". That's not the case here;
you have a parent form.
To refer to a parent form, use this syntax:
Forms!frmBrowseAllTasks.Filter = strWhere

-Tom.
Microsoft Access MVP
 
K

Keri

Hi Tom,

Thank you for the reply. I have made the changes in the code but know I'm
getting an error message 2450 can not find form referred to. I'm not sure
why that came up. I was wondering if you might know.

Thanks,
Keri
 
T

Tom van Stiphout

On Wed, 15 Oct 2008 05:51:01 -0700, Keri

If that happened on this line:
Forms!frmBrowseAllTasks.Filter = strWhere
then one of two things is going on: that form is not open, or the form
name is incorrect.

-Tom.
Microsoft Access MVP
 
K

Keri

Does the form matter if its unbound? I've tried looking into the problem
more but I clueless at this point. I'm not sure why it doesn't reginized the
name when the name of the form is Browse All Tasks. I mean I told it to open
the form by why isn't not wanting to filter it?

Thanks,
keri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top