Results 1 to 4 of 4
  1. #1
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328

    Filter for year from data in mm/dd/yy format

    Using Access 2007. I have form that includes a list of race dates in format mm/dd/yy. I want to filter the dates to display all races run in a certain year entered in a field in the form header. I just don’t seem to know how to do it.

    Form.Filter = "Year(DateRace)= 2019" 'This works , displays all year 2019 races.
    Form.Filter = "Year(DateRace) = Me.YrRace" This blanks the form. Why?

    Me.YrRace is a field where the user enters 4 digits for the year of interest.


    Any help much much appreciated. Driving me nuts.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    More like:

    "Year(DateRace) = " & Me.YrRace
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Paul-Works! Thanks for such a quick answer. I idiotically chased things on the web and other places and wasted a couple of hours. I still don't understand it, but ---.

    Thanks again, I really appreciate the quick answer. Should have done this rather than trying this and that.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help! Whatever is inside the quotes is passed to the database engine, which can't interpret the term reference. The solution is to concatenate the form value into the string.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-10-2019, 01:49 PM
  2. Replies: 4
    Last Post: 05-19-2017, 06:20 AM
  3. Replies: 10
    Last Post: 02-20-2017, 06:00 PM
  4. Replies: 3
    Last Post: 06-13-2016, 03:26 PM
  5. Dsum data between to dates for this year and last year
    By sdel_nevo in forum Programming
    Replies: 1
    Last Post: 06-13-2013, 06:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums