DateAdd() (1 Viewer)

PatAccess

Registered User.
Local time
Today, 11:36
Joined
May 24, 2017
Messages
284
Hello Guys,

I am trying to set a field 1 or 2 years out from another date (another field)and I used the DateAdd function but it is giving me an error Error 438 - Object doesn't support this property or method

Here is my code:

Private Sub SetDate_Click()
Dim NewDate As Date
NewDate = DateAdd("y", 1, Me.Expires) 'Me.Expires is the field with old date
SetDate = Me.NewExp
End Sub

What am I doing wrong? :banghead:

Thank you
 

RuralGuy

AWF VIP
Local time
Today, 09:36
Joined
Jul 2, 2005
Messages
13,826
I suspect that the Me.Expires object is not a DateTime field.
 

RuralGuy

AWF VIP
Local time
Today, 09:36
Joined
Jul 2, 2005
Messages
13,826
Try:
NewDate = DateAdd("yyyy", 1, Me.Expires) 'Me.Expires is the field with old date
 

Gasman

Enthusiastic Amateur
Local time
Today, 15:36
Joined
Sep 21, 2011
Messages
14,044
Shouldn't it be
SetDate = NewDate ?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:36
Joined
Oct 29, 2018
Messages
21,358
Hi. Which line is highlighted when you go to Debug?
 

PatAccess

Registered User.
Local time
Today, 11:36
Joined
May 24, 2017
Messages
284
Hello Guys,
I figured it out.
First of all, I had to declare a new variable Olddate and and assign an existing field to it then I had to make so Olddate = Me.Expires
Then set my field with the new values
Me.NewExp=SetDate

Thank you all
 

Users who are viewing this thread

Top Bottom