Date Calc Question

J

jbc

Hello,

I would like Access to perform a calculation. I have:

checkbox called chkIsRenewal
textbox called intYears
textbox called txtExpirationDate

When chkIsRenewal is checked I would like the intYears to
be added to txtExpirationDate.

I would also like the formula to make sure that the
expiration date is the LAST day of the month.

This would save a lot of problems, especially during leap
year when I can't remember how many days are in a month!

Thanks.

jbc
 
J

jbc

I got it to work by using:

If IsDate(Me.txtExpirationDate2) Then

Me.txtExpirationDate2 = DateSerial(Year
(Me.txtExpirationDate2) + intYears, Month
(Me.txtExpirationDate2) + 1, 0)

End If

jbc
 
A

Alan Fisher

-----Original Message-----
Hello,

I would like Access to perform a calculation. I have:

checkbox called chkIsRenewal
textbox called intYears
textbox called txtExpirationDate

When chkIsRenewal is checked I would like the intYears to
be added to txtExpirationDate.

I would also like the formula to make sure that the
expiration date is the LAST day of the month.

This would save a lot of problems, especially during leap
year when I can't remember how many days are in a month!

Thanks.

jbc
.

Add the following code to the After Update event of
chkIsRenewal:
Dim currdate As Date
Dim int1 as integer
int1 = me.intYears
currdate = DateAdd("YYYY", int1, txtExpirationDate)
currdate = DateSerial(Year(currdate), Month(currdate) + 1,
0)
txtExpirationDate = currdate

You might want to do an If Then Else statement to check
the value of the checkbox and only run the code if the box
is in fact checked.
 

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