Add a year to date field

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

Guest

I have two date fields "LastCalDate" and "DueDate". I would like DueDate to
autofill with the next years date (i.e. LastCalDate = 7/21/07 then
DueDate=7/21/08). What code do I use?

Thanks
 
Thank you for the quick response. Where do I place this code, "Build an
event", in the Query, etc, etc

Thanks

Douglas J. Steele said:
DateAdd("yyyy", 1, [LastCalDate])

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Bonnie43 said:
I have two date fields "LastCalDate" and "DueDate". I would like DueDate to
autofill with the next years date (i.e. LastCalDate = 7/21/07 then
DueDate=7/21/08). What code do I use?

Thanks
 
If you are talking about fields in a table, you don't need a DueDate field.
In fact it is incorrect to have a DueDate field! Anywhere you want to
display the Due Date in a form or report, just put this expression in an
unbound textbox:
=DateAdd("yyyy", 1, [LastCalDate])

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
The most common place for it would be in a query.

--

Lynn Trapp
Microsoft MVP (Access)
www.ltcomputerdesigns.com


Bonnie43 said:
Thank you for the quick response. Where do I place this code, "Build an
event", in the Query, etc, etc

Thanks

Douglas J. Steele said:
DateAdd("yyyy", 1, [LastCalDate])

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Bonnie43 said:
I have two date fields "LastCalDate" and "DueDate". I would like DueDate
to
autofill with the next years date (i.e. LastCalDate = 7/21/07 then
DueDate=7/21/08). What code do I use?

Thanks
 
Thank you for your quick response. So I just make a text box and include the
name of the field on the query?

Lynn Trapp said:
The most common place for it would be in a query.

--

Lynn Trapp
Microsoft MVP (Access)
www.ltcomputerdesigns.com


Bonnie43 said:
Thank you for the quick response. Where do I place this code, "Build an
event", in the Query, etc, etc

Thanks

Douglas J. Steele said:
DateAdd("yyyy", 1, [LastCalDate])

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have two date fields "LastCalDate" and "DueDate". I would like DueDate
to
autofill with the next years date (i.e. LastCalDate = 7/21/07 then
DueDate=7/21/08). What code do I use?

Thanks
 
Steve, that worked great, but I have to click in the box to get it to
populate. Is there a way to have it automatically update once I change the
date in LASTCAL? Thanks

Steve said:
If you are talking about fields in a table, you don't need a DueDate field.
In fact it is incorrect to have a DueDate field! Anywhere you want to
display the Due Date in a form or report, just put this expression in an
unbound textbox:
=DateAdd("yyyy", 1, [LastCalDate])

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




Bonnie43 said:
I have two date fields "LastCalDate" and "DueDate". I would like DueDate to
autofill with the next years date (i.e. LastCalDate = 7/21/07 then
DueDate=7/21/08). What code do I use?

Thanks
 
Try pressing <Enter> after you enter a date in LastCalDate.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Bonnie43 said:
Steve, that worked great, but I have to click in the box to get it to
populate. Is there a way to have it automatically update once I change the
date in LASTCAL? Thanks

Steve said:
If you are talking about fields in a table, you don't need a DueDate
field.
In fact it is incorrect to have a DueDate field! Anywhere you want to
display the Due Date in a form or report, just put this expression in an
unbound textbox:
=DateAdd("yyyy", 1, [LastCalDate])

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




Bonnie43 said:
I have two date fields "LastCalDate" and "DueDate". I would like DueDate
to
autofill with the next years date (i.e. LastCalDate = 7/21/07 then
DueDate=7/21/08). What code do I use?

Thanks
 
If you do what was suggested in a query, you can then make that field the
record source for a textbox on a form


--

Lynn Trapp
Microsoft MVP (Access)
www.ltcomputerdesigns.com


Bonnie43 said:
Thank you for your quick response. So I just make a text box and include
the
name of the field on the query?

Lynn Trapp said:
The most common place for it would be in a query.

--

Lynn Trapp
Microsoft MVP (Access)
www.ltcomputerdesigns.com


Bonnie43 said:
Thank you for the quick response. Where do I place this code, "Build an
event", in the Query, etc, etc

Thanks

:

DateAdd("yyyy", 1, [LastCalDate])

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have two date fields "LastCalDate" and "DueDate". I would like
DueDate
to
autofill with the next years date (i.e. LastCalDate = 7/21/07 then
DueDate=7/21/08). What code do I use?

Thanks
 
The information updates in the field, but does not remain there when I exit
the screen. What could I be doing wrong?

Steve said:
Try pressing <Enter> after you enter a date in LastCalDate.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Bonnie43 said:
Steve, that worked great, but I have to click in the box to get it to
populate. Is there a way to have it automatically update once I change the
date in LASTCAL? Thanks

Steve said:
If you are talking about fields in a table, you don't need a DueDate
field.
In fact it is incorrect to have a DueDate field! Anywhere you want to
display the Due Date in a form or report, just put this expression in an
unbound textbox:
=DateAdd("yyyy", 1, [LastCalDate])

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




I have two date fields "LastCalDate" and "DueDate". I would like DueDate
to
autofill with the next years date (i.e. LastCalDate = 7/21/07 then
DueDate=7/21/08). What code do I use?

Thanks
 
You're doing nothing wrong! DueDate is unbound so it disappears when you
exit the screen.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Bonnie43 said:
The information updates in the field, but does not remain there when I
exit
the screen. What could I be doing wrong?

Steve said:
Try pressing <Enter> after you enter a date in LastCalDate.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Bonnie43 said:
Steve, that worked great, but I have to click in the box to get it to
populate. Is there a way to have it automatically update once I change
the
date in LASTCAL? Thanks

:

If you are talking about fields in a table, you don't need a DueDate
field.
In fact it is incorrect to have a DueDate field! Anywhere you want to
display the Due Date in a form or report, just put this expression in
an
unbound textbox:
=DateAdd("yyyy", 1, [LastCalDate])

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




I have two date fields "LastCalDate" and "DueDate". I would like
DueDate
to
autofill with the next years date (i.e. LastCalDate = 7/21/07 then
DueDate=7/21/08). What code do I use?

Thanks
 
If I want the date to remain, should i create a bound box? This date is used
to show our auditor at a glance when our next CALDATE is.

Steve said:
You're doing nothing wrong! DueDate is unbound so it disappears when you
exit the screen.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Bonnie43 said:
The information updates in the field, but does not remain there when I
exit
the screen. What could I be doing wrong?

Steve said:
Try pressing <Enter> after you enter a date in LastCalDate.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Steve, that worked great, but I have to click in the box to get it to
populate. Is there a way to have it automatically update once I change
the
date in LASTCAL? Thanks

:

If you are talking about fields in a table, you don't need a DueDate
field.
In fact it is incorrect to have a DueDate field! Anywhere you want to
display the Due Date in a form or report, just put this expression in
an
unbound textbox:
=DateAdd("yyyy", 1, [LastCalDate])

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




I have two date fields "LastCalDate" and "DueDate". I would like
DueDate
to
autofill with the next years date (i.e. LastCalDate = 7/21/07 then
DueDate=7/21/08). What code do I use?

Thanks
 
If I want the date to remain, should i create a bound box? This date is used
to show our auditor at a glance when our next CALDATE is.

Storing derived data such as this in your table accomplishes
three things: it wastes disk space; it wastes time (almost
any calculation will be MUCH faster than a disk fetch); and
most importantly, it risks data corruption. If one of the
underlying fields is subsequently edited, you will have data
in your table WHICH IS WRONG, and no automatic way to detect
that fact.

Just redo the calculation whenever you need it, either as a
calculated field in a Query or just as you're now doing it -
in the control source of a Form or a Report textbox.

John W. Vinson [MVP]
 
Thank you for your response. I don't know if I am not explaining myself
right. This database is for tool calibration. I have a field that shows the
date calibrated, and I want to add a year to a new field so when I try to
run a report next year to determine tools to pull, this will be used (This is
instead of typing out the date and making an error. If using the control
source is right, I don't understand why the date disappears. How does this
help me accomplish my goal?
 
Thank you for your response. I don't know if I am not explaining myself
right. This database is for tool calibration. I have a field that shows the
date calibrated, and I want to add a year to a new field so when I try to
run a report next year to determine tools to pull, this will be used (This is
instead of typing out the date and making an error. If using the control
source is right, I don't understand why the date disappears. How does this
help me accomplish my goal?

The goal is to be able to bring up a tool, and see when its due date comes
next. Correct?

One way to do so is to store the due date in the table, along with the
calibration date.

Another way - the *preferred* way in most cases - to do so is to store ONLY
the calibration date in the table, and display to the user a Form, or a
Report, or a Query in which you *CALCULATE* the due date.

If you're assuming that the due date must be stored in your table in order for
the user to see it, that assumption is incorrect and is the source of your
confusion.


John W. Vinson [MVP]
 
Back
Top