Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2012
    Posts
    17

    Unanswered: Open Form Filtered by Date Paramaters

    Hi all,

    Probably very easy...I'm looking to filter viewed records when a form is opened to display only those that are less than 30 days..

    I have an event procedure upon page load that runs the following code

    DoCmd.OpenForm "form name", acViewNormal, , "Date(Field)" > Date - 30

    This filter does not seem to be working.. any ideas
    Last edited by darrenj; 04-23-13 at 05:19.

  2. #2
    Join Date
    Jan 2009
    Location
    Kerala, India
    Posts
    183
    Code:
    DoCmd.OpenForm "form name", acViewNormal, , "[FieldName] < " & "#" &  Date - 30 & "#"
    www.MsAccessTips.com (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by apr pillai View Post
    Code:
    DoCmd.OpenForm "form name", acViewNormal, , "[FieldName] > " & "#" &  Date - 30 & "#"
    should work
    however it may be smarter to use the functions rather than rely on the way Access/JET implements dates

    Code:
    DoCmd.OpenForm "form name", acViewNormal, , "[FieldName] > " & dateadd("d",-30,date())
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Mar 2012
    Posts
    17

    Thumbs up Thank ...

    I'll give it a go, many thanks

Posting Permissions

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