First Date of selected month

Ihussein

Registered User.
Local time
Today, 14:19
Joined
Nov 11, 2015
Messages
47
Hello,
I have the following function to return the first date of the selected month, which it's getting the value of the selected month from txtDateOfPlan.
apparently it's returning the first date of the current monthly what ever the selection is.
Your kind support please
Regards

Function FirstDayInMonth(Optional dtmDate As Variant) As Date
If IsMissing(dtmDate) Then
dtmDate = Date
Else
dtmDate = txtDateOfPlan
End If

FirstDayInMonth = DateSerial( _
Year(dtmDate), Month(dtmDate), 1)
End Function

Private Sub txtDateOfPlan_AfterUpdate()
txtDateOfPlan = FirstDayInMonth
End Sub
 
Where in your code do you tell the function what moth you have selected ?
With the code you gave us, that behavior is totally normal and works fine.
 
Yes, I fully agree with you, just after reading your reply, I got the missing point and I managed to resolve it. it's about the If statement that I'm using. I have removed it, and as I'm calling the function in the after update event this will ensure that dtmDate value will never equal Null or Zero. I guess
Thanks for your prompt reply
 

Users who are viewing this thread

Back
Top Bottom