JohnMunich
JohnMunich

Reputation: 631

access fields same but not equal?

i'm using the following code to compare two recordsets:

For i = 1 To (recordsetA.Fields.Count - 1)
    If recordsetA.Fields(i).Value <> recordsetB.Fields(i).Value Then
        stringFieldList = stringFieldList & ", " & recordsetA.Fields(i).Name
    End If
Next i

However in the stringFieldList there are a couple of fields which have the same values (like 1339.5). Why?

Upvotes: 1

Views: 989

Answers (1)

Fink
Fink

Reputation: 3436

Since it sounds like your dealing with double datatypes, the proper way for the test would be to set a limit, then test the absolute difference. You will also need to think about handling a null value.

Const epsilon as double = 0.00001

If Abs(recordsetA.Fields(i).Value - recordsetB.Fields(i).Value) < epsilon Then
'do stuff here
End If

Upvotes: 3

Related Questions