dATE USER DEFINED FUNCTION TO WORK AS CRITERIA IN A QUERY (1 Viewer)

LOUISBUHAGIAR54

Registered User.
Local time
Today, 12:24
Joined
Mar 14, 2010
Messages
157
I have written a user defined function that calculates the end of the current month. This I named EndOfThisMonth. It works well as a function. Now I would like to use it as date criteria to include in a query. The function is included as such EndOfThisMonth().

The field on which this function is to enter as a criteria is another calculated date function called Due.

When I run this query I get an error message saying Undefined Function 'EndOfThisMonth' in expression.

Could someone be of help in trying to help me get this to work and tell me why I get this error message please ?


Louis
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 05:24
Joined
Jan 20, 2009
Messages
12,852
Declare the function as Public in a Standard Module.

BTW The last day of any month is quite easy with built in functions.

Code:
DateSerial(Year(somedate), Month(somedate)+1,0)
 

LOUISBUHAGIAR54

Registered User.
Local time
Today, 12:24
Joined
Mar 14, 2010
Messages
157
Many thanks for your reply. Do you think I can use this in built function as the criterion. If so instead of somedate I will insert Date()
for today.

Thanks again.

Louis
 

LOUISBUHAGIAR54

Registered User.
Local time
Today, 12:24
Joined
Mar 14, 2010
Messages
157
In fact I used the in built function named Dateserial as a criterion in the query and it has worked well.

Many thanks for your suggestion.


Louis;)
 

Users who are viewing this thread

Top Bottom