I am trying to code a combo box in a form such that it automatically filters the options as the user types. I have a code but I keep getting a compile error. Here is my code:
Private Sub UTIL_FCLTY_ID_Change()
If Nz(Me.UTIL_FCLTY_ID.Text) = “” Then
Me.Form.Filter = “”
Me.FilterOn = False
ElseIf Me.UTIL_FCLTY_ID.ListIndex <> -1 Then
Me.Form.Filter = “[UTILITY FACILITY TYPE NAME:] = ‘” & _
Replace(Me.UTIL_FCLTY_ID.Text, “‘”, “””) & “‘”
Me.FilterOn = True
Else
Me.Form.Filter = “[UTILITY FACILITY TYPE NAME:] Like ‘*” & _
Replace(Me.UTIL_FCLTY_ID.Text, “‘”, “””) & “*'”
Me.FilterOn = True
End If
Me.UTIL_FCLTY_ID.SetFocus
Me.UTIL_FCLTY_ID.SelStart = Len(Me.UTIL_FCLTY_ID.Text)
End Sub
“”) instead of plain quotes (""). If your real code also includes typesetting quotes, you should change them to plain quotes.& “*'”? That looks like a quote problem ... notice how it affects the syntax coloring at that point.