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!

Date Functions

Status
Not open for further replies.

Muzzy

Programmer
Dec 14, 2001
68
GB
I have a date field on a form. which is in format yyyy so displays 2002. I want another field (txtNextYear) to say 2003 and tried this by using the following code:

DateAdd("yyyy",1,"txtCurrentDateOriginal")

(txtCurrentDateOriginal having the value of 2002)

This doesn't work, I get #Error, can anyone help?

Cheers

Muzzy
 
Try:

DateAdd("yyyy",1,Me![txtCurrentDateOriginal])

You were passing a string to a date function, but this will pass the date...

If we knew what it was we were doing, it would not be called research, would it? - Albert Einstein [atom]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Unfortunately didn't work, any other ideas? Or what I might be doing to get the above formula wrong?

cheers

Muzzy
 
Try this:

DateAdd("yyyy",1,cvdate(Me![txtCurrentDateOriginal]))

I hope this helps.

John
 
Or maybe try this:

DateAdd("yyyy",1,Val(Me![txtCurrentDateOriginal])

HTH
Binky ::)
><>
 
Hi,
You must first convert the value in the text field to a date. Use the CDate function to accomplish this.

txtNextYear = DateAdd(&quot;yyyy&quot;,1,CDate(Me.txtDate)) Hope it helps. Let me know what happens.
With regards,
PGK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top