Increase a date field by 12 month

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
 
M

Marshall Barton

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?
 
J

Jeff Boyce

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
 
G

Gilles

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?
 
M

Marshall Barton

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
 
G

Gilles

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
 
G

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?
 
J

Jeff Boyce

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
 
G

Gilles

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
 

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