Log in

View Full Version : Access 2013 VBA Datediff help!



TJenner2
12-03-2014, 06:24 AM
It sounds simple. I have have it working with the NOW() function, but when I use two Short Date fields, I get nothing returned.

This works:

Days_in_Store.Value = DateDiff("d", Date_Entered, Now())

This does not work. Why?

Days_in_Store.Value = DateDiff("d", Date_Entered, Date_Sold)

TJenner2
12-03-2014, 06:53 AM
If it helps this is what I am contending with:

The Date_Entered field is chosen by the Date Picker Calender. The Date_Sold is controlled by a check box that once checked, uses the NOW() function to enter a date into this field.

Date_Entered Looks like this: 9/25/2014
Date_Sold Looks like this: 12/3/2014 8:14:24 AM

I set the format on both of them to Short Date in the Form as well as the Table, so they both look like the Date_Entered on the form.

TJenner2
12-03-2014, 07:20 AM
Here is another discovery. If I rap Date_Entered with Cdate like so Cdate(Date_Entered) I get the same results, but if I rap the Date_Sold with Cdate like so Cdate(Date_Sold), I get a runtime error of "Invalid use of Null".

TJenner2
12-03-2014, 07:37 AM
ISSUE RESOLVED. It was a logic error, I was trying to update the Days_in_Store before I was updating the Sold_Date. Thanks for those of you who took the time to look at this.