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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incrementing date by dropdown box of years

Status
Not open for further replies.

avayaman

Technical User
Nov 6, 2002
841
CA
Poeple here were so helpful yesterday & I am just learning, so I thought I would see if anyone can write a VB routine to accomplish this:

I have a database of club members (North American Truck Camper Owners Association or NATCOA)

When a new record is established, I want it to place a date in the date field, 3 months or 90 days ahead, if easier. The field is in the format of Month/day/year eg 01/31/06. In other words there is a 3 month grace period on expiry. I then want to put a drop down box (I know how to do this. With the number of years in it, ie 1,2,3,4,5....

Here is what I want to happen. When I create a new record, the date field inserts todays date plus 3 months (or 90 days). If the day is over 28, I want it reset to 28 so it's valid, no matter what the month. I don't care about the 29,30 & 31 it's only 3 days. Obviously if the month is 12 it needs to go to 2, and the year advance by 1. If it is possible to advance the current date 90 days & do all this in one go, that would be better & easier.

I then want to go to the drop down box & select a number, I want the curent year incremented by that number. In other words if it is say 2009, I want it changed to 2011 if I select 2. I am not worried about the century change I will be dust by then.

A bit tougher than what I asked for yesterday.

Paul Beddows

Consulting, Avaya/EAS implementation, Training
Vancouver, Canada
E-mail paul at natcoa.com
 
Check out the Day(), Month(), and Year() functions along with simple math. It should give you what you are looking for. Any questions post back.
 
...more specifically,

Private Sub Form_AfterInsert()
txtDate = DateAdd("m",3,Date)
End Sub


Private Sub cboYears_AfterUpdate()
txtExpiryDate = DateAdd("y",cboYears,txtDate)
End Sub

 
Thanks guys it was actually a bit more complex than I posted, but you pointed me int he right direction. Mission accomplished.

Now I want to generate a report of memberships that are within 60 days of their expiry or past their expirry when I open the database. I think I should be able to figure that one out.



Paul Beddows

Consulting, Avaya/EAS implementation, Training
Vancouver, Canada
E-mail paul at natcoa.com
 
It should be fairly easy, but if you can't let us know.

Ascent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top