Problem with decimal places

Crash101

New member
Local time
Today, 08:11
Joined
Dec 23, 2023
Messages
16
Everyone,

I have a very simple data value. This is 0.01. Here the immediate printout:


TradeSetNo: 1
TradeNo: 1
CurrentBalance: 200,000.00
TraderID:
RiskPercent: 0.01
Generated SQL: INSERT INTO tblTradeEntry (tblTE_RiskPercent_dbl) VALUES (0.01)

So it appears to be working. However when I look at tblTE_RiskPercent_dbl is always appears as 0.0000.

Any ideas why?

Crash101
 
Possibly the data type is wrong? Your field name suggests it is a double. Depending on the precision with which values are stored, you might be losing the precision required.

Another approach, which could be more useful, would be to define that field as Currency, which is accurate to four decimals.

Try that on a backup copy and see what happens.
 
@GPGeorge yes that works as a currency. Seems strange that it does work as double even with 4 decimals etc. Any other ideas with making it work as a number with 2 decimals?
 
always appears as 0.0000.

In what context does it show up as 0.0000 ??? Because that is not a "natural" format for double-precision numbers. A natural format would be 0.0 if you don't impose formatting. BUT if you imposed a particular format to four decimal places on an INTEGER data type (BYTE, WORD, LONG, INTEGER, or - if you have the right version of Access - QUAD), you would also get 0.0000 - because you can't actually store the 0.01 into an integer, but if that field is formatted, you can easily get back as many vacuous decimal places as you wish - none of which will ever amount to anything.
 
tblTE_RiskPercent_dbl has following properties and it comes up as 0.00 even though it is formatted as 0.00 with 2 decimal places.
Format - Fixed
Decimal Places 2
Input Mask
Caption
Default Value 0
Validation Rule
Validation Text
Required
Indexed
Text Align

So it is a Large Number. However, if I run it if it is a currency field. 0.01 is recorded.

Also I am using Access 365, the only version I have access to.

I attach some screenshots.
 

Attachments

  • decimal place.PNG
    decimal place.PNG
    9 KB · Views: 82
  • Decimal Place2.PNG
    Decimal Place2.PNG
    33.6 KB · Views: 83
  • Field Properties.PNG
    Field Properties.PNG
    6 KB · Views: 80
Thanks Guys - Cracked it. Its not a large number, just a number as a double. I thought large number was for a decimal. Woops.

Its just a number, formated to two decimal places.

Awesome help on this forum!!

Crash101
 
Thanks Guys - Cracked it. Its not a large number, just a number as a double. I thought large number was for a decimal. Woops.

Its just a number, formated to two decimal places.

Awesome help on this forum!!

Crash101
As the linked article explains, "Large Number" was added to Access for compatibility with SQL Server's Big Int data type.
 
So it appears to be working. However when I look at tblTE_RiskPercent_dbl is always appears as 0.0000.
Do you have a format on the table for that field? NEVER format data in tables. It can mask the actual value.
 

Users who are viewing this thread

Back
Top Bottom