Results 1 to 3 of 3
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2003
    Join Date
    Jun 2016
    Posts
    237

    Six month earlier

    Hi,
    I am trying to check a date field to see if it is less than six months of today's date using VBA.
    How can this be done. The field name to compare is DateOfExpiry



    Khalil

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    You want code behind a form and reference field value of current record?

    Something like:

    If Me!DateOfExpiry > DateAdd("m", -6, Date()) Then

    What event do you want to use?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2003
    Join Date
    Jun 2016
    Posts
    237
    Thanks.
    If I understand correctly, m stands for the months
    -6 stands for less than 6 months

    It worked for me after changing the > to <
    Here is how it looks like:

    If ([frmPassportsSubForm].Form![DateOfExpiry]) < DateAdd("m", -6, Date) Then

    Khalil

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

Similar Threads

  1. Replies: 4
    Last Post: 06-06-2020, 12:24 AM
  2. Replies: 6
    Last Post: 02-24-2019, 09:03 AM
  3. Replies: 2
    Last Post: 08-01-2017, 01:40 AM
  4. Replies: 2
    Last Post: 02-15-2017, 06:07 PM
  5. User input but one year earlier
    By jhaynes in forum Queries
    Replies: 3
    Last Post: 10-19-2012, 10:51 AM

Tags for this Thread

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