开发者

access fields same but not equal?

开发者 https://www.devze.com 2023-02-16 01:14 出处:网络
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

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).开发者_如何学C Why?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消