dbTalk Databases Forums  

Calculating an upcoming date

comp.databases.ms-access comp.databases.ms-access


Discuss Calculating an upcoming date in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
BamaBlast
 
Posts: n/a

Default Calculating an upcoming date - 10-22-2010 , 12:00 PM






I am a novice Access user!

I am creating a Access 2003 database and I am stuck currently on one
of many issues. I have a Date field and I have a Span field that is
formated as a number and I want that number to be claculated as days.
I need to add the number of days in the Span field to the Date field
and have it populate another field. for example:

10/22/2010 + 30days = Due Date

the "Date" field and the "Span" field are different in every record.

All help is appreciated!

Sincerely,

BB

Reply With Quote
  #2  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Calculating an upcoming date - 10-22-2010 , 12:14 PM






BamaBlast wrote:
Quote:
I am a novice Access user!

I am creating a Access 2003 database and I am stuck currently on one
of many issues. I have a Date field and I have a Span field that is
If it is really called "Date", you should change the name to one that is
not a reserved keyword. "Date" is the name of a function and its use as
a field name can cause some very hard-to-diagnose problems. You can see
a list of reserved keywords here:
http://www.aspfaq.com/show.asp?id=2080, but the easiest way to avoid
these keywords is to be more descriptive when naming your fields. In
this case, what is this date? Is it the date the record was created? In
that case, call it CreationDate (note that I am avoiding using spaces in
my field names - this is a best practice that you should follow as
well).

Quote:
formated as a number and I want that number to be claculated as days.
I need to add the number of days in the Span field to the Date field
and have it populate another field. for example:

10/22/2010 + 30days = Due Date

the "Date" field and the "Span" field are different in every record.

All help is appreciated!

Sincerely,

In the top row of the query grid, in an empty column, enter:

DueDate: DateAdd("d",[Span],[Date])




--
HTH,
Bob Barrows

Reply With Quote
  #3  
Old   
BamaBlast
 
Posts: n/a

Default Re: Calculating an upcoming date - 10-22-2010 , 01:41 PM



On Oct 22, 1:14*pm, "Bob Barrows" <reb01... (AT) NOyahoo (DOT) SPAMcom> wrote:
Quote:
*BamaBlast wrote:
Bob,

Thanks for the information, it was most helpful! Thanks for the
refresher on reserved words, I had not made that mistake but I was not
actually thinking about it though. About once every year and half I'm
asked by my employer to create a database for various tasks (this is
my 3rd) so I have to re-learn all of the things I learned the previous
time. So I am sure that I will have many more questions as I muddle
through such as this one below:

Based on you suggestion above and some research I solved my problem by
using this string in the Contol Source of a field in my form.

=DateAdd("d",[Span],[PreviousMx]) this populates my [NextDueMx] field
in the form but does not populate the field in the table. I
understand why (because I changed the control source) but i can't
figure out how to get this newly calculated [NextDueMx] date to show
up in a table field. I have tried a copy and paste macro with no
success.

Thx as always.

Reply With Quote
  #4  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Calculating an upcoming date - 10-22-2010 , 02:02 PM



BamaBlast wrote:
Quote:
On Oct 22, 1:14 pm, "Bob Barrows" <reb01... (AT) NOyahoo (DOT) SPAMcom> wrote:
BamaBlast wrote:

Bob,

Thanks for the information, it was most helpful! Thanks for the
refresher on reserved words, I had not made that mistake but I was not
actually thinking about it though. About once every year and half I'm
asked by my employer to create a database for various tasks (this is
my 3rd) so I have to re-learn all of the things I learned the previous
time. So I am sure that I will have many more questions as I muddle
through such as this one below:

Based on you suggestion above and some research I solved my problem by
using this string in the Contol Source of a field in my form.

=DateAdd("d",[Span],[PreviousMx]) this populates my [NextDueMx] field
in the form but does not populate the field in the table. I
understand why (because I changed the control source) but i can't
figure out how to get this newly calculated [NextDueMx] date to show
up in a table field. I have tried a copy and paste macro with no
success.

Well, actually, that is a good thing. Calculated values should not be
stored. They should be calculated as needed. This relieves you of the
task of making sure the calculated values are updated when any of the
values that go into the calculation change.. You should create a saved
query that uses the DateAdd expression to generate the NextDueMix
column. Use the saved query as your form or report source and you're
done.

When should caclulated values be stored? One case where you need to
store them is where you need to retrieve historical results, i.e., what
was the result when the value was calculated 1 year ago, compared to
when it is calculated today, and you don' have the values that went into
the prior year's calculation. Another is where the calculation bogs down
performance unacceptably. That should not be the case in your situation.

--
HTH,
Bob Barrows

Reply With Quote
  #5  
Old   
BamaBlast
 
Posts: n/a

Default Re: Calculating an upcoming date - 10-22-2010 , 02:27 PM



I will have to trust you on this one. I will try to create a Query
next week and see if it provides me with the calculated dates as
needed. I know that I will need to be pulling reports using that
date.

Thank you once again! Have a wonderful weekend!

Reply With Quote
  #6  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Calculating an upcoming date - 10-22-2010 , 03:23 PM



BamaBlast wrote:
Quote:
I will have to trust you on this one. I will try to create a Query
next week and see if it provides me with the calculated dates as
needed. I know that I will need to be pulling reports using that
date.

Thank you once again! Have a wonderful weekend!
Just to be clear, the query you create should return all the fields in
your table plus the calculated field

--
HTH,
Bob Barrows

Reply With Quote
  #7  
Old   
NoodNutt
 
Posts: n/a

Default Re: Calculating an upcoming date - 10-23-2010 , 06:50 AM



G'day BB

Just a side note to help with any possible future confusion when refering to
tables, fields and query's, I find it easier to label each item as follow:

Name Examples:

tblMyTable
txtMyTextboxControl
qryMyQuery
frmMyForm
cmbMyCombo
rptMyReport

etc.....

This way, if you happen to use the same name/label for a table, query, form
or report, you can then differentiate.

Cheers

HTH
Mark.

Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.