Combo Box Subform Filtering Problem

lemon_balm

Registered User.
Local time
Today, 00:54
Joined
Feb 7, 2006
Messages
65
Hi all

I have been using some code from this site to filter my forms and subforms via a selection of combo boxes. However, when I try to filter by either date or callid, I get runtime error 2001 and the debugger drops in at the first forms!filter line. This seems to work perfectly well for the other 3 combos that I use. Is it to do with the type of fields I am trying to filter with or am I missing something integral to the code? Each combo is named Filter1, Filter2, etc and the name of the field to filter by is placed in the tag line for the corresponding combo box.

Private Sub Command13_Click()

Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 5
If Me("Filter" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " _
& " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & _
" And "
End If
Next

If strSQL <> "" Then
' Strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 5))
' Set the Filter property.
forms!frmoutershell.frminnershell.Form.frminnerinnershell.Form.Filter = strSQL
forms!frmoutershell.frminnershell.Form.frminnerinnershell.Form.FilterOn = True
End If
forms!frmoutershell.frminnershell.Form.lblfilter.Caption = strSQL
End Sub

Any help would be appreciated as I am getting quite frustrated with it only working on certain parts of the form.

Regards

Jason
 
This !!

forms!frmoutershell.frminnershell.Form.frminnerinn ershell.Form

Doesn't look like a valid name for a form or subform

Forms!YourFormName!YourSubformName.Filter = strSQL

Also try to avoid spaces in your form or control names. If you do include spaces, put brackets around

Forms![Your Form Name]![Your Subform Name].Filter = strSQL


Hope this helps?
 
Hi,

Thanks for the reply. The spaces in the code are from cutting and pasting into this forum. However, you are correct, the 2nd form word should not be there forms!frmoutershell.frminnershell.Form.frminnerinnershell.Form.Filter = strSQL

The 3rd form declares the location fir filtering though.

Regards

Jason
 
scratch that comment. all code is required otherwise an error comes up stating that Object doesn't support this method
 

Users who are viewing this thread

Back
Top Bottom