locked
Validate RRS feed

  • Question

  • User-1499457942 posted

    Hi 

      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

     msg="error"

         End If

         If msg <> "" Then 

     MsgBox(msg, 16, "Report Validation")

     

         End If

    End Function

    Thanks

    Monday, December 25, 2017 7:10 AM

All replies

  • User347430248 posted

    Hi JagjitSingh,

    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)".<sub></sub><sup></sup>

    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.

    Regards

    Deepak

    <sub></sub><sup></sup><sub></sub><sup></sup>

    Monday, January 1, 2018 1:23 AM