Code to Calculate Days

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need assistance with the following. I have five Fields and must Calculate
Storage Days.

Date Received (Date/Time)
Date Stuffed (Date/Time)
Date Delivered (Date/Time)
Date Shipped (Date/Time)
Storage Days (Number, Calculated Field)

Here is what I want to accomplish:
If Date Received, Date Delivered and Date Shipped has value then Calculate
Storage Days (Which would be the difference between Received and Delivered
Dates)
Then If Date Received, Date Stuffed and Date Shipped has values then
calculate Storage Days (Which would be the difference Stuffed and Shipped
Dates)

Thanks
 
You shouldn't be storing a calculated value. Instead, create a query with a
computed field in it, and use the query wherever you would otherwise have
used the form.

To determine whether a particular field has a value, use the IsNull
function.

IIf(IsNull([Date Received]), 0, IIf(IsNull([Date Shipped] or IsNull([Date
Delivered], 0, DateDiff("d", [Date Shipped], [Date Delivered])))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top