VBA-- add one year , base on the date of another textbox

  • Thread starter Martin \(Martin Lee\)
  • Start date

M

Martin \(Martin Lee\)

I have textbox1 and textbox2

The user will enter the DATE into textbox1 (for example: 2007-03-25 or
2007-09-18 etc)

My question is£º
After the user input the date into TEXTBOX1, How to make TEXTBOX2
automatically generate a new date which add one year base on TEXTBOX1 ( for
example TEXTBOX2 will automatically be 2008-03-25 or 2008-09-18)


What's the VBA should be (for add up one year) ?


Thanks!

Martin LEE
2007-03-13
 
Ad

Advertisements

M

missinglinq via AccessMonster.com

Private Sub TextBOX1_BeforeUpdate(Cancel As Integer)
Me.TextBox2.Value = DateAdd("yyyy", 1, Me.TextBOX1.Value)
End Sub
 
S

storrboy

I have textbox1 and textbox2

The user will enter the DATE into textbox1 (for example: 2007-03-25 or
2007-09-18 etc)

My question is£º
After the user input the date into TEXTBOX1, How to make TEXTBOX2
automatically generate a new date which add one year base on TEXTBOX1 ( for
example TEXTBOX2 will automatically be 2008-03-25 or 2008-09-18)

What's the VBA should be (for add up one year) ?

Thanks!

Martin LEE
2007-03-13


Add the folllowing to the AfterUpdate event for textbox1, .

Me!Textbox2 = DateAdd("yyyy",1,Me!Textbox1)
'DateAdd(interval, number, date) See help topic for more help

If Textbox2 is not bound, then you cann use the dateadd function in
the ControlSource
 
S

storrboy

Private Sub TextBOX1_BeforeUpdate(Cancel As Integer)
Me.TextBox2.Value = DateAdd("yyyy", 1, Me.TextBOX1.Value)
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted viahttp://www.accessmonster.com


There might not be a value in the textbox in the BeforeUpdate event.
If you do the work here, the use the Text property of the texbox.
 
Ad

Advertisements

Joined
Aug 29, 2013
Messages
1
Reaction score
0
My questions is & it is almost similar as the above: the user input the date into a range of cells (F:F)
How to make (G:G) automatically generate a new date which add one year base on Rang F.
For example F2 08/29/2013
F2 will automatically be 08/29/2014 so on so on..
Thank you all
 

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