Comparision of two records

Hi can we campare two records for their equality… eg : if rec = xrec or tab1 <> tab2…or is there any other way two check two records for their equality or nonequality. thanx kumar

1 Like

I have not seen other ways to do it, than checking every field like if name <> xrec.name or address <> xrec.address Then … You could make a function to encapsulate the checking, like CustRecIsEqual(Rec1, Rec2):Boolean And then use the function like if CustRecIsEqual(Rec, xRec) Then … Rgds Janus

Hi janus Thanks for the answer, actually i have done as u said, but i wanted know if there is anyother way, in case the no of fields in the table are many. any how thanx kumar

Hi, Try this with Atains new Datatype Variant: Variant1 := Rec; Variant2 := xRec; message(’%1’,Variant1 = Variant2) This wil give Yes, even if records are different. But if you move the variant datatypes to text. Text1 := format(variant1); Text2 := format(variant2); message(’%1’,Text1 = Text); This will do the trick. There is a ‘minor’ problem, text can be 1024 positions maximum.

Hi Willy i tried testing as you said, but it shows only the currenct record. It wasnt working as u said… Kumar

Hi Kumar, The message should only show a yes or no. Besides, there is a very simple solution (which i overlooked while playing with variant types) to compare records: if format(Rec) <> format(xRec) then … Hope this helps

Hi willy i have made inital tests and it works fantastic…but the previous one doesnt give me any yes or no as i said earlier it completely displays the current record…this for u to continue your research…any way thanx a lot kumar Edited by - mvgs on 2002 Feb 01 12:18:53