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

DateAdd problem

Status
Not open for further replies.

wvmbark

Technical User
Feb 12, 2003
135
US
It's the little simple things that drive a person to madness...

On a form, I have 3 text boxes: Date1, Days1, and ResultDate. I want to key a date into Date1; a number of days into Days1, and ResultDate will display will Date1+Days1 as a date.

I've tried:
DateAdd("d",[Days1],[Date1]) and I get Name? in ResultDate.

Date([Date1])+[Days1].

Why don't these work? Thanks for the help!!!

Mike

 
In the AfterUpdate event procedure of Date1 and Days1 you may code something like this:
Me!ResultDate = CDate(Me!Date1) + Nz(Me!Days1, 0)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for your help, I will give a try. Can you tell me why the DateAdd function doesn't work?

Mike
 
wvmbark
On the AfterUpdate event for Days1, try...

Me.ResultDate = Me.Date1 + Me.Days1

Tom
 
Thank you both for your help but I don't know code yet. Do I need to open Code Builder to drop the code in or just place it in the field next to AfterUpdate? When I do the latter I get an error stating something about a macro not being saved...

Mike
 
Open the form in Design view. Right click on the Days1 control and then select Properties. Next, click on the elipses (the ...) at the right of the AfterUpdate event, and type in the desired code.

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top