I have a subform and I want to control the data displayed depending on a selection of combo boxes and list boxes on the main form.
I am trying this code from a command box on the main form
___________________________________________________________
Private Sub Command17_Click()
Dim strHSERegion As String
Dim strROC As String
Dim strFilter As String
' Build criteria string for HSE Region field
If IsNull(Me.cboHSERegion.Value) Then
strHSERegion = "Like '*'"
Else
strHSERegion = "='" & Me.cboHSERegion.Value & "'"
End If
' Build criteria string for ROC field
If IsNull(Me.lstROC1.Value) Then
strROC = "Like '*'"
Else
strROC = "='" & Me.lstROC1.Value & "'"
End If
' Combine criteria strings into a WHERE clause for the filter
strFilter = "[HSERegion] " & strHSERegion & " AND [ROC] " & strROC
' Apply the filter and switch it on
With [Forms]![Startup]![sbfrmStartUpMember]
.Filter = strFilter
.FilterOn = True
End With
End Sub
___________________________________________________________
It goes into debug and The line of code
.Filter = strFilter
is highlighted with the message
"Run time error 438"
"Object does'nt support this property or method"
___________________________________________________________
Any help much appreciated
I am trying this code from a command box on the main form
___________________________________________________________
Private Sub Command17_Click()
Dim strHSERegion As String
Dim strROC As String
Dim strFilter As String
' Build criteria string for HSE Region field
If IsNull(Me.cboHSERegion.Value) Then
strHSERegion = "Like '*'"
Else
strHSERegion = "='" & Me.cboHSERegion.Value & "'"
End If
' Build criteria string for ROC field
If IsNull(Me.lstROC1.Value) Then
strROC = "Like '*'"
Else
strROC = "='" & Me.lstROC1.Value & "'"
End If
' Combine criteria strings into a WHERE clause for the filter
strFilter = "[HSERegion] " & strHSERegion & " AND [ROC] " & strROC
' Apply the filter and switch it on
With [Forms]![Startup]![sbfrmStartUpMember]
.Filter = strFilter
.FilterOn = True
End With
End Sub
___________________________________________________________
It goes into debug and The line of code
.Filter = strFilter
is highlighted with the message
"Run time error 438"
"Object does'nt support this property or method"
___________________________________________________________
Any help much appreciated