So I need to return the last day of a field called [Period]. If the value of the field is #05/14/2018#, I want to return #05/31/2018#. I created the following public function;
Public Function LastDayOfMonth(D As Date) As Date
Dim LDOM As Date
Dim NM As Date
NM = DateAdd("m", 1, D)
LDOM = DateSerial(Year(NM), Month(NM), "1")
LDOM = DateAdd("d", -1, LDOM)
LastDayOfMonth = LDOM
End Function
When I try to use it in a query ...
LDOM:LastDayOfMonth([Period])
I get an error message "Undefined function 'LastDayOfMonth' in expression.
I'm thinking I've either 'parked' the code in the wrong location, or I'm not calling it correctly. I appreciate any help!!
Public Function LastDayOfMonth(D As Date) As Date
Dim LDOM As Date
Dim NM As Date
NM = DateAdd("m", 1, D)
LDOM = DateSerial(Year(NM), Month(NM), "1")
LDOM = DateAdd("d", -1, LDOM)
LastDayOfMonth = LDOM
End Function
When I try to use it in a query ...
LDOM:LastDayOfMonth([Period])
I get an error message "Undefined function 'LastDayOfMonth' in expression.
I'm thinking I've either 'parked' the code in the wrong location, or I'm not calling it correctly. I appreciate any help!!