Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add year(s) to current date 1

Status
Not open for further replies.

BakerUSMC

Technical User
May 24, 2003
96
0
0
US
Hello to all,

I have a form that contains the fields 'Term of Sponsorship', 'Start of Sponsorship' and 'End of Sponsorship'.

In the field 'Term of Sponsorship', the user picks from a combo box either, 1 year or 2 years, or 3 years and so on...

In the field 'Start of Sponsorship', the user enters a date.

In the field 'End of Sponsorship', I need the new date the sponsorhip will end on depending on the number of years selected and the date entered.

So for example:

Term: 1 year or 2 years
Start: 09/15/2005 09/15/2005

End: 08/15/2006 08/15/2007

How do I do this via VBA? Thanks for your help!!!!

BakerUSMC
 
The DateDiff function can do this. The help files can steer you to the correct syntax much better than I can.

Frank kegley
fkegley@hotmail.com
 
[End of Sponsorship] = DateSerial(Year([Start of Sponsorship])+[Term of Sponsorship], Month([Start of Sponsorship]), Day([Start of Sponsorship])-1)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for your quick responses...

In the field 'Term of Sponsorship' where the user selects either 1 Year, 2 Years and so on... The value stored in the table for the field is 1 year or 2 Years... there is no numerical value stored.

How can this be done??

Thanks again
 
[End of Sponsorship] = DateSerial(Year([Start of Sponsorship])+Val([Term of Sponsorship]), Month([Start of Sponsorship]), Day([Start of Sponsorship])-1)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

Thanks so much for your quick help... It worked perfectly... You've always been a big help for me and others...

You definitly deserve a star!!!

Thanks again!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top