Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2008
    Posts
    163

    Unanswered: applying filters in code

    I have a form that contains alphanumeric IDs, I want to create a filter for all IDs according to year. The filter will apply afterupdate on a combo box.

    The combo box is populated by two digit numbers representing years (05, 06, 07, etc).

    The ID pattern is letter-year-dash-sequence (A08-0001). I intend to use a filter that follows something like "*08-*" (the dash is important so that it does not count similar numbers in the sequence part).

    The code below doesn't work (yes, I'm that kind of a newbie to try deformed sql statements in VBA):

    Private Sub YearListTag_AfterUpdate()
    If IsNull(Me.YearListTag) Then
    Me.FilterOn = False
    Else
    Me.Filter = "SID = like "*Me.YearListTag-*"
    Me.FilterOn = True
    End If
    End Sub
    What's the proper code for this? Thanks! =)

    btw, what's the VBA for removing filters?
    Last edited by coffeecat; 07-22-08 at 01:35.

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Change

    Me.Filter = "SID = like "*Me.YearListTag-*"

    to

    Me.Filter = "SID Like *" & Me.YearListTag & "-*"

    The rest looks ok to me.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Jun 2008
    Posts
    163
    Thanks, but it's giving me error 2448, "you can't assign a value to this object".

    am I missing out something relevant? =(
    Last edited by coffeecat; 07-22-08 at 03:21.

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Might be my bad here...

    Me.Filter = "SID Like *" & Me.YearListTag & "-*"

    Should be:

    Me.Filter = "SID Like ""*" & Me.YearListTag & "-*"""
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Jun 2008
    Posts
    163
    You are officially the patron saint of MS Access.

    Seriously, thanks! =D

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Wow! I just got promoted! ^^

    You're welcome btw
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •