Expand my Community achievements bar.

Compare 2 dates - LC ES ver 8.2

Avatar

Level 1

Hello,

This may seem to be a very elementary questions but I am missing something that I have not been able to identify and am asking for anyone's assitance with this.

In my form I am comparing two dates (<Date1> and <Date2>).  If <Date2> is less that <Date1> I would like to display a message box and then set the focus to <Date1>.

I have tried numerous variations using Date2Num and .Rawvalue but the code seems to be skipping the IF THEN statement and goes directly to displaying the message.  On Exit from the <Date2> field the message box appears regardless if the date is less than, equal to, or greater than <Date1.

Here is the code...

topmostSubform.Page1.<Date2>::exit - (FormCalc, client)

if

(Date2Num(<Date2>,"DD-MMM-YY") < Date2Num(<Date1>,"DD-MMM-YY")) then

xfa.host.messageBox("<<< CAUTION >>> Your <Date2> cannot be earlier than your <Date1>. Please correct your <Date1> date. Thank You")

xfa.host.setFocus("<Date1>")

Endif

Thanks.

TST

1 Reply

Avatar

Former Community Member

When referencing an object you do not use <Date1> ....you woudl use the name of the field and a method or property. In your case ....assuming the field is called Date1 then you woudl use Date1.rawValue

Paul