A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Adding Dates



 
 
Thread Tools Display Modes
  #1  
Old January 28th, 2008, 05:58 PM posted to microsoft.public.access.forms
Ange Kappas
external usenet poster
 
Posts: 52
Default Adding Dates

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 ?


  #2  
Old January 28th, 2008, 06:40 PM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default Adding Dates

On Mon, 28 Jan 2008 19:58:48 +0200, Ange Kappas wrote:

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:
DepartureateAdd("d",[Days],[ArrivalDate])

Directly on a form or in a report, using an unbound text control:
=DateAdd("d",[Days],[ArrivalDate])
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #3  
Old January 28th, 2008, 07:07 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Adding Dates

On Mon, 28 Jan 2008 19:58:48 +0200, "Ange Kappas" wrote:

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]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:21 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.