Date*1 year???

satty

Board Regular
Joined
Jan 12, 2003
Messages
68
hey people,

i have a text box on a form called txtStartDate. i also have another text box just below is called txtExpiryDate.

i was wondering if somebody could help me with this lil 'glitch'.

The Problem

what i want is, when i enter a date in the Start Date, for example, 27/12/03. i want the expiry date to automatically come with 27/12/04, exactly one year difference.

thanx guys!



Satty
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Simply add code that updates txtExpiryDate upon entering txtStartDate.

To do this, right click on the txtStartDate variable and select Properties.
Go to the Event tab and click on "After Update" and select "Code". Paste the following code:

Code:
Private Sub txtStartDate_AfterUpdate()
    
    If txtStartDate.Value > 0 Then
        txtExpiryDate = DateSerial(Year(txtStartDate) + 1, Month(txtStartDate), Day(txtStartDate))
    End If

End Sub

(the first and last line should already be there for you).

Now it should automatically update txtExpiryDate upon updating txtStratDate.
 
Upvote 0

Forum statistics

Threads
1,221,604
Messages
6,160,748
Members
451,670
Latest member
Peaches000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top