VB-Access Filter in Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • juanchodavid
    New Member
    • Feb 2008
    • 4

    VB-Access Filter in Form

    Hi,
    I'm having this problem, seems no big deal but I just don't find the way to solve it: I have a field in a form where the user writes a filter criteria and then accepts by pressing a button. The filter works good until the user uses the ' * ' in the search field. In that case no data is shown. The simplest example is when the only filter criteria is *. All the data should be shown, but by this filter method no data at all is shown.

    The part of the code is:
    Code:
    Form.filter="Segment " & = '" & Field.Value & "'"
    Form.FilterOn = True
    Any ideas?
    Thanks!
    Last edited by NeoPa; May 22 '08, 01:01 PM. Reason: [CODE] tags
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Originally posted by juanchodavid
    Hi,
    I'm having this problem, seems no big deal but I just don't find the way to solve it: I have a field in a form where the user writes a filter criteria and then accepts by pressing a button. The filter works good until the user uses the ' * ' in the search field. In that case no data is shown. The simplest example is when the only filter criteria is *. All the data should be shown, but by this filter method no data at all is shown.

    The part of the code is:
    Form.filter="Se gment " & = '" & Field.Value & "'"
    Form.FilterOn = True

    Any ideas?
    Thanks!
    Try changing your syntax for the filter as follows:

    Form.filter="Se gment = '" & Field.Value & "'"

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32661

      #3
      Try the following :
      Code:
      Me.Filter = "[Segment] Like '" & Field.Value & "'"
      Me.FilterOn = True
      This allows the operator to specify whether he wants to use pattern matching or only an exact match.

      Comment

      • juanchodavid
        New Member
        • Feb 2008
        • 4

        #4
        Originally posted by NeoPa
        Try the following :
        Code:
        Me.Filter = "[Segment] Like '" & Field.Value & "'"
        Me.FilterOn = True
        This allows the operator to specify whether he wants to use pattern matching or only an exact match.
        Thanks a lot! it solved the problem

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          No problem - Pleased it helped :)

          Comment

          Working...