Increase a date field by 12 month

  • Thread starter Thread starter Gilles
  • Start date Start date
G

Gilles

Here is the situation

I have a form named "Payment_frm"
The date source is a table named "Payment_tbl"
The field is named "Payment_Date" it is a date field
When I add a new record using the form I would like to have the Payment
_Date to automatically be the next month date.

Thanks

Gilles
 
Gilles said:
I have a form named "Payment_frm"
The date source is a table named "Payment_tbl"
The field is named "Payment_Date" it is a date field
When I add a new record using the form I would like to have the Payment
_Date to automatically be the next month date.


Thins line in the form's BeforeUpdate event procedure:

Me.[Payment_Date] = DateAdd("m", 1, Date)

might be what you want?
 
You've asked a "how to" question.

Why? It sounds like you've already decided that you need to store a date
that's one month after a date you've already stored?!

Why not just store the one date and use a query to determine "plus one
month"?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Sorry it didn't work.

It needs to look at the last record and evaluate the date ex.(26 jun 08) and
in the new record store the new date which would be 26 jul 08.

I am having a hard time figuring this one out


Thanks

Marshall Barton said:
Gilles said:
I have a form named "Payment_frm"
The date source is a table named "Payment_tbl"
The field is named "Payment_Date" it is a date field
When I add a new record using the form I would like to have the Payment
_Date to automatically be the next month date.


Thins line in the form's BeforeUpdate event procedure:

Me.[Payment_Date] = DateAdd("m", 1, Date)

might be what you want?
 
Gilles said:
Sorry it didn't work.

Might have something to do how well you explained what you
wanted it to do?

It needs to look at the last record and evaluate the date ex.(26 jun 08) and
in the new record store the new date which would be 26 jul 08.


Now there is the question if how you define "last record".
If you mean the last recoed in the form's record source
**query**, then, assuming the same date field in bith
records, try:

With Me.RecordsetClone
.MoveLast
Me.Payment_Date = DateAdd("m", 1, !Payment_Date)
End With
 
I tried that Jeff and it does give me the next month date, but now I need
this new date to be in the original date field when a new record is added

Thanks, all ideas are welcome

Gilles
 
You are right, I may not have explain it properly.

This is done using a form
I have a date field
When I create a new record I would like the date field to automatically give
me the date one month later . Example if I type today "7 Jul 2008" in that
date field, I would like the next record to be added to show "7 Aug 08"

tks

Gilles

Gilles said:
Sorry it didn't work.

It needs to look at the last record and evaluate the date ex.(26 jun 08) and
in the new record store the new date which would be 26 jul 08.

I am having a hard time figuring this one out


Thanks

Marshall Barton said:
Gilles said:
I have a form named "Payment_frm"
The date source is a table named "Payment_tbl"
The field is named "Payment_Date" it is a date field
When I add a new record using the form I would like to have the Payment
_Date to automatically be the next month date.


Thins line in the form's BeforeUpdate event procedure:

Me.[Payment_Date] = DateAdd("m", 1, Date)

might be what you want?
 
It all starts with the data ... and I don't have a very clear picture of how
your data is structured.

"How" depends on how your data is organized.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Thank you all

This works
With Me.RecordsetClone
.MoveLast
Me.Payment_Date = DateAdd("m", 1, !Payment_Date)
End With

I putted it on the Get Focus event and it work like a charm

Appreciate it

Gilles
 
Back
Top