I have a function that converts a date into a date "code" for my customer (i.e. January = "A", February = "B", etc). Ideally, I want the function to convert a passed date, but if no date was passed, just use today's date. I started with this:
Public Function DateCode(Optional ByVal DateToCalc As Date = Nothing) As String
...but the problem is that when I don't pass anything, the date is still set to "something", namely: " #12:00:00 AM#". I can't set the default value for the optional variable DateToCalc to "Now.Date", as it gives me an error "Constant expression is required". I tried to verify that this was not a valid date like this:
If
Not IsDate(DateToCalc) Then DateToCalc = Now..but this is still "OK", because it is technically still a date/time. I realize that I am probably missing something simple [stupid] and I would appreciate any suggestions.
Thank you.