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

References for DateAdd function

Status
Not open for further replies.

weezles

Technical User
Jul 18, 2003
81
GB
hi

Do I need to set any references to use the DateAdd function?

I'm trying to use the following code which i cant see anything wrong with

PrevDate = DateAdd(m, 6, Me.txtDate)

however i'm receiving an error stating that 'm' is a variable not defined.

I've started using a new pc and wondered if it was something to do with references set on this machine.

Thanks

Lou
 
You don't need a reference.

There's two places you could immediately have looked.

The first was in the VBA Editor itself when the pop up appears telling you about arguments. It specifies that the first argument in the DateAdd() function is a String.

The other place you could have looked is the MS Access Help Files - always the first port of call when unsure or learning about something.

Anyway, your question:

You have the argument as m but Access thinks this is an unspecified variable. And, as the arguement expected is a String, you should change this to "m".

Stewart J. McAbney | Talk History
 
Unfortunately I couldn't look at the help files as they were not installed on the machine. I had tried using quotes, however at that point i was just using an actual date and not a variable. Had to enclose both the m and the date variable in quotes to get it to work.

Thanks for your help

Lou
 
If you're getting a message that m is not defined it is probably because you have Option Explicit set in the General section of the code and you haven't defined m in a Dim statement. In this case it should be
Dim m as Integer
It is generally good practice to declare all variables
Simon Rouse
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top