Last post Jan 01, 2018 01:23 AM by Deepak Panchal
Dec 25, 2017 07:10 AM|JagjitSingh|LINK
I have Date parameters Fromdate & Todate. I want to validate ToDate . Its' Month & Year should be same as FromDate.
I have written below code but not working
Function CheckValidation(StartDate as Date, EndDate as Date) as Integer
Dim msg as String
msg = ""
If (Month(StartDate) <> Month(EndDate) And Year(StartDate) <> Year(EndDate)) Then
If msg <> "" Then
MsgBox(msg, 16, "Report Validation")
Jan 01, 2018 01:23 AM|Deepak Panchal|LINK
I can see you had posted the code.
what happened actually when you run the report?
did you get any error message?
I can see you had wrote 2 if conditions. did you check whether both if conditions working properly or not?
if not, please try to check the value of "Month(StartDate),Month(EndDate) ,Year(StartDate),Year(EndDate)".
it is possible that one of the value is not correct or have some issue.
and because of "And" operator, the whole if condition get false and nothing happened.
so instead of writing 2 if condition, you can write IF...Else condition.
so when condition get false then also it go to the Else part and you can display some message there.
so you can know that condition is working properly or not.
try to make a test on your side and let us know about the results.
we will try to provide you further suggestions to solve the issue.