Adding Dates

A

Ange Kappas

I have a field with arrival date then a field with days and another field
with departure date. I enter a date in the arrival date field, then I put in
how many days as a number in the days field and using a Macro command on
exit I want the departure date to show automatically the arrival date plus
the days.
How do I do it ?
 
F

fredg

I have a field with arrival date then a field with days and another field
with departure date. I enter a date in the arrival date field, then I put in
how many days as a number in the days field and using a Macro command on
exit I want the departure date to show automatically the arrival date plus
the days.
How do I do it ?

You don't.
Access is a database, not a spreadsheet.
All you need do is store (in your table) the [ArrivalDate] and the
[Days].
Then whenever you need the Departure date, simply calculate it.
In a query:
Departure:DateAdd("d",[Days],[ArrivalDate])

Directly on a form or in a report, using an unbound text control:
=DateAdd("d",[Days],[ArrivalDate])
 
J

John W. Vinson

I have a field with arrival date then a field with days and another field
with departure date. I enter a date in the arrival date field, then I put in
how many days as a number in the days field and using a Macro command on
exit I want the departure date to show automatically the arrival date plus
the days.
How do I do it ?

Set the Control Source of the departure date command to

=DateAdd("d", [NumberOfDays], [ArrivalDate])

You should almost surely NOT store all three values in your table, since the
departure date can be calculated from the other two. If you store all three
then you'll be at risk of data anomalies such as ArrivalDate = 1/27/2008,
NumberOfDays = 100, and DepartureDate = 2/1/2008. One of these must be wrong
but there's no immediate way to tell which!

John W. Vinson [MVP]
 

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

Top