Next year

  • Thread starter Thread starter Curmudgeon
  • Start date Start date
C

Curmudgeon

We're scheduling tours for next year (2006) by entering, for example,
1/10/06 into a date field. For this year (2005) we can simply enter,
for example, 12/25 and the year autofills to 12/25/05.

Question: is there a property or simple code that will convert a dd/mm
entry into next year IF it is prior to today Date()? Thank you, Access
masters, for any help and for providing a lot of interesting reading
here at this newsgroup.
 
Hi, Curmudgeon.

You can use the control's AfterUpdate event procedure to compare the date
entered to the result of the Now() function, which returns the current date.
Then add a year:

If [YourDate] < Now() Then
[YourDate] = DateAdd("yyyy", 1, [YourDate])
End If

Sprinks
 
Sprinks said:
Hi, Curmudgeon.

You can use the control's AfterUpdate event procedure to compare the
date entered to the result of the Now() function, which returns the
current date. Then add a year:

If [YourDate] < Now() Then
[YourDate] = DateAdd("yyyy", 1, [YourDate])
End If

It's probably better to use the Date() function instead of Now(), which
also returns the time as well as the date. Probably in this case
they're not going to be entering tour dates that start today, but if
they did they might not get the result they want.
 
There we have it, Dick. Works like a charm. Yes, we'll use Date().
Many thanks for the rapid and elegant answer.
 
Curmudgeon said:
There we have it, Dick. Works like a charm. Yes, we'll use Date().
Many thanks for the rapid and elegant answer.

Thank Sprinks; I just donated two cents. :-)
 

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

Back
Top