Hello im trying to use the indicated vb below in a change event of combo-box named cbofilter within a main form where there is a subform, and I am trying to filter a field called company, I believe every aspect of the code is correct, according to what field name I have at least.... but unfortunately the [Company] field is getting end of statement error. and I've uploaded the access file which I've created a sample of what I am trying to work on
Note that. I have set the combo-box properties:
limit to list : no
Auto expand : no
here's the code
Code:
Private Sub cboFilter_Change()
If Nz(Me.cboFilter.Text) = “” Then
Me.Form.Filter = “”
Me.FilterOn = False
ElseIf Me.cboFilter.ListIndex <> -1 Then
Me.Form.Filter = “[Company] = ‘” & _
Replace(Me.cboFilter.Text, “‘”, “””) & “‘”
Me.FilterOn = True
Else
Me.Form.Filter = “[Company] Like ‘*” & _
Replace(Me.cboFilter.Text, “‘”, “””) & “*'”
Me.FilterOn = True
End If
Me.cboFilter.SetFocus
Me.cboFilter.SelStart = Len(Me.cboFilter.Text)
End Sub
thank you in advance.