'Runtime Error 2448'

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I keep getting 'Runtime Error 2448' when I run the code below. When I debug
it highlights me.Filter=strWhere. Any suggestions??

Private Sub Filter_Click()
Dim strWhere As String
Dim lngLen As Long

If Not IsNull(Me.TypeFilter) Then
strWhere = strWhere & "([Type]=""" & Me.TypeFilter & """)And"
End If
If Not IsNull(Me.StatusFilter) Then
strWhere = strWhere & "([Status]=""" & Me.StatusFilter & """)And"
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)

Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub

Private Sub Form_Open(Cancel As Integer)
'Me.Filter = "(False)"
'Me.FilterOn = True

End Sub

Private Sub RemoveFilter_Click()
Dim ctl As Control

For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next
Me.FilterOn = False
End Sub

Private Sub Ticket__Click()
DoCmd.OpenForm "ISTroubleTicket", , ,
"[ISTroubleTicket]![Ticket#]=Forms![TroubleTicket query]![Ticket#]"
End Sub
 
Firstly the form must be bound (something in its RecordSource property) in
order to be filtered.

If it is bound, the filter string may be invalid. For example, you may have
omitted some spaces. Just to hightlight it, I've used {SPACE} where you need
to use a space:
strWhere = strWhere & "([Type]=""" & Me.TypeFilter &
"""){SPACE}And{SPACE}"
 
Allen, this is your code, I got it from the Search2000.mdb so I'm sure it
looked familiar to you. The spaces worked, so thank you so much for the code
and your reply to my post. You are a guru and I have bookmarked your site
for further help.

Thanks again.!
Ryan

Allen Browne said:
Firstly the form must be bound (something in its RecordSource property) in
order to be filtered.

If it is bound, the filter string may be invalid. For example, you may have
omitted some spaces. Just to hightlight it, I've used {SPACE} where you need
to use a space:
strWhere = strWhere & "([Type]=""" & Me.TypeFilter &
"""){SPACE}And{SPACE}"

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ryan said:
I keep getting 'Runtime Error 2448' when I run the code below. When I
debug
it highlights me.Filter=strWhere. Any suggestions??

Private Sub Filter_Click()
Dim strWhere As String
Dim lngLen As Long

If Not IsNull(Me.TypeFilter) Then
strWhere = strWhere & "([Type]=""" & Me.TypeFilter & """)And"
End If
If Not IsNull(Me.StatusFilter) Then
strWhere = strWhere & "([Status]=""" & Me.StatusFilter & """)And"
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)

Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub

Private Sub Form_Open(Cancel As Integer)
'Me.Filter = "(False)"
'Me.FilterOn = True

End Sub

Private Sub RemoveFilter_Click()
Dim ctl As Control

For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next
Me.FilterOn = False
End Sub

Private Sub Ticket__Click()
DoCmd.OpenForm "ISTroubleTicket", , ,
"[ISTroubleTicket]![Ticket#]=Forms![TroubleTicket query]![Ticket#]"
End Sub
 
Back
Top