Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    New Zealand
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts

    date() minus 6 months (Access 97)

    I want a message box to pop up if the date entered is > 6 months before 'today'. I know how to make a message box with criteria, I just need to know the bit of code that tests for '6 months prior to today'. Can anyone help me? Thanks

  2. #2
    Lounger
    Join Date
    Nov 2001
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: date() minus 6 months (Access 97)

    If Me.MyDate> DateAdd("m",-6,Date()) Then
    on the Before Update event of the control

  3. #3
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: date() minus 6 months (Access 97)

    The answer you received gives you most of the details, but I suspect from you post that you want to display the message only if the date entered is more than 6 months in the past. If that's the case you will want to make the GreaterThan sign a LessThan sign.
    Wendell

  4. #4
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    New Zealand
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: date() minus 6 months (Access 97)

    Thanks for the code. I found that using 'date' didn't work on all computers, though. But replacing it with 'now' it did.
    Thanks again for the help.

  5. #5
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: date() minus 6 months (Access 97)

    Very strange - the code depends on the computer clock being reasonably accurate so that could be the problem. FYI, Date() creates a date with the time portion set to midnight (12AM in some parts of the world), while Now() gives you the current date and time in the computer clock.
    Wendell

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: date() minus 6 months (Access 97)

    I had a problem where Date didn't work but Now did, and it turned out to be a references problem. On the computers where date didnt work, trim and left didn't work either.

    In any code window, code to tools references and look for any "Missings".
    Regards
    John



  7. #7
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    New Zealand
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: date() minus 6 months (Access 97)

    Wow, it is just great being able to get all this useful advice. Thanks again.
    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>

Posting Permissions

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