I'm trying to setup a function in my module to run code based on the date in a user form matching the last day of the previous month, so it might look something like:
Code:
If [Forms]![main_form]![date] = DateSerial(Year(Date), Month(Date), 0) Then
'do stuff
Else
'do other stuff
End If
Here's the funny thing - I can't get the form date to match the DateSerial. Down in the immediate window I double checked this:
Print DateSerial(Year(Date), Month(Date), 0)
7/31/2017 (correct)
Print DateSerial(Year(Date), Month(Date), 0) = "7/31/2017"
True (correct)
Print [Forms]![main_form]![date]
7/31/2017 (correct)
Print [Forms]![main_form]![atb_date] = "7/31/2017"
True (correct)
Print [Forms]![main_form]![date] = DateSerial(Year(Date), Month(Date), 0)
False (what????)
What am I missing to make the DateSerial equal to the form?