Solved Using a single precision field as condition (1 Viewer)

XPS35

Active member
Local time
Today, 19:27
Joined
Jul 19, 2022
Messages
159
I use the Dutch versions of Access and Windows. That means that the decimal separator is set to a comma by default.
In a table I have a numeric field (single precision). Entering and displaying values works fine for this field.
However, if I use the field as a condition in a function, I get an error. For example, the following function returns an error:
Code:
MsgBox DSum("ItemValue", "MyTable", "ItemValue <= " & Me.ItemValue)
The error is:
enkeleprecisie.jpg

[syntax error (comma) in query expression ....]

How do I modify the code to get a good result?
 

ebs17

Well-known member
Local time
Today, 19:27
Joined
Feb 7, 2020
Messages
1,946
The criteria in DSum expects an SQL filter, in English with US formats. Therefore, the comma must be treated.
Code:
MsgBox DSum("ItemValue", "MyTable", "ItemValue <= " & Str(Me.ItemValue))
 

XPS35

Active member
Local time
Today, 19:27
Joined
Jul 19, 2022
Messages
159
Thanks, that works.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:27
Joined
Feb 19, 2002
Messages
43,275
Just FYI, if you never need more than 4 decimal places of precision, then it is far better to use the currency data type than single or even double as long as we are talking about a range that can be supported by currency. Don't confuse the currency data type with the currency format. The currency data type is a scaled integer. Ie 1.009 is actually stored as 10090. The implied decimal position is ALWAYS four from the right. The currency data type does not suffer from floating point errors and so will always be more accurate when used in compare operations.
 

Users who are viewing this thread

Top Bottom