Results 1 to 4 of 4
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Same dates different fields compare


    Is there a way to have an if in vba that looks at two dates fields and if they are the same run one command vs if they are not the same?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    You can declare them as date data types and then compare

    dim dtOne as date
    dim dtTwo as Date

    If dtone <> dtTwo then

    Do one thing

    else

    Do a few different things

    end if

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Cheers thanks

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Just be careful if there are hours and minutes involved. You may need to parse the time...... it can get tricky. So test and compare your results.

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

Similar Threads

  1. How to compare dates in two form fields
    By wardw in forum Forms
    Replies: 4
    Last Post: 09-16-2013, 10:05 AM
  2. Compare dates in vba
    By rjbautista20 in forum Programming
    Replies: 1
    Last Post: 08-17-2012, 09:44 AM
  3. Replies: 1
    Last Post: 02-17-2012, 04:43 PM
  4. Query input dates for range of dates in two fields
    By kagoodwin13 in forum Queries
    Replies: 3
    Last Post: 02-13-2012, 04:25 PM
  5. Compare two fields!
    By finditsol in forum Forms
    Replies: 1
    Last Post: 02-11-2010, 01:43 PM

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