Hi that is an alternative.
I have tried using the code itself , it is working but still Im not satisfied... 🙂 the code is below. As you told I have used a hidden parameter then from there I called the function.
But problem is because of the Err.Raise(6,Report) the return value is not a string type so that the parameter is not getting the value, ie the validation of the hidden paramter is not satisfied and so the report wont run this is what we need.
But the problem is it will show a message as the validation failed for the parameter... 🙁
Can any experts help on this...?
Public Function MyFunction(S as Datetime,E as Datetime) as String
Dim msg as string
msg=""
if(S>E) then
msg = "Start Date Should not be greater than End Date"
end if
If msg <> "" Then
MsgBox(msg, 16, "Report Validation")
Err.Raise(6,Report) 'Raise an overflow
end if
Return msg
End Function
You can see this if you call the function from a text box rather than the hidden parameter, but there the report will run even though it is checking the Start date and End Date...
Thanks & Regards,
MC