Hi there--
I'm having a heck of a time trying to create a field of data type decimal.
It seems like, according to the docs, the following two statements should
work just fine:
ALTER TABLE Table1 ADD COLUMN Field1 DECIMAL(10,2);
ALTER TABLE Table1 ADD COLUMN Field1 DECIMAL;
Yet both run-time error 3932 "Syntax error in field definition". Using
other data types (bit, money, double, text, etc) there's no problem.
This is Access 2000, using plain old DAO.
Thanks in advance for any insight!
Kevin 6 7533
Kevin Microsoft did not update DAO to support the creation of a DECIMAL
field type. You need to execute your DDL query under ADO to create the
table, e.g.:
strSql = "ALTER TABLE Table1 ADD COLUMN Field1 DECIMAL(10,2);"
CurrentProject. Connection.Exec ute strSql
Personally, I consider it an advantage of DAO that it does not support this
field type. JET has no idea how to handle it. Would you be happy if it could
even handle as basic a query as this:
SELECT Field1 FROM Table1 ORDER BY Field1;
Details in:
Incorrect Sorting (Decimal fields)
at: http://allenbrowne.com/bug-08.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Kevin Chambers" <My********@MyN ame.DontSpamMe. UncleSam> wrote in message
news:dq******** *@enews4.newsgu y.com... Hi there--
I'm having a heck of a time trying to create a field of data type decimal. It seems like, according to the docs, the following two statements should work just fine:
ALTER TABLE Table1 ADD COLUMN Field1 DECIMAL(10,2); ALTER TABLE Table1 ADD COLUMN Field1 DECIMAL;
Yet both run-time error 3932 "Syntax error in field definition". Using other data types (bit, money, double, text, etc) there's no problem.
This is Access 2000, using plain old DAO.
Thanks in advance for any insight!
Kevin
This is quite a serious drawback to JET decimal fields, Allen. Thank
you for bringing it to our attention.
If anyone is saddled with a Decimal Field, or must use one (I can't
think of any reason why this might be so) I believe one can achieve a
correct descending sort by using an ADODB Recordset as follows:
Sub temp()
Dim r As ADODB.Recordset
Set r = New ADODB.Recordset
With r
.Open "SELECT * FROM Table3", CurrentProject. AccessConnectio n,
adOpenStatic, adLockReadOnly
.Sort = "a_decimal_fiel d desc"
While Not .EOF
Debug.Print .Collect(0)
.MoveNext
Wend
End With
End Sub
I am not, of course, suggesting that is ideal or convenient.
I disagree with your (web-site) comments about VBA Decimals. They are a
bit clumsy, but they are a simple way to to effect accurate large whole
number arithmetic such as 792281625142643 37593543950335 / 5. If there
is a better way I would be glad to know it.
Thanks for your comments Lyle.
Regarding VBA, sometimes you must use the type (particularly if the value
must be more than 4 decimal places and too large for Currency), but it is
less efficient to use a Variant, requires more scrupulous error-checking,
and you still can't declare a constant of type Decimal AFAIK.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Lyle Fairfield" <ly***********@ aim.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. . This is quite a serious drawback to JET decimal fields, Allen. Thank you for bringing it to our attention. If anyone is saddled with a Decimal Field, or must use one (I can't think of any reason why this might be so) I believe one can achieve a correct descending sort by using an ADODB Recordset as follows:
Sub temp() Dim r As ADODB.Recordset Set r = New ADODB.Recordset With r .Open "SELECT * FROM Table3", CurrentProject. AccessConnectio n, adOpenStatic, adLockReadOnly .Sort = "a_decimal_fiel d desc" While Not .EOF Debug.Print .Collect(0) .MoveNext Wend End With End Sub
I am not, of course, suggesting that is ideal or convenient.
I disagree with your (web-site) comments about VBA Decimals. They are a bit clumsy, but they are a simple way to to effect accurate large whole number arithmetic such as 792281625142643 37593543950335 / 5. If there is a better way I would be glad to know it.
Allen Browne wrote: ... and you still can't declare a constant of type Decimal AFAIK.
This is True but quite good results may be achieved with a constant
Variant of SubType string. eg.
Const d As Variant = "79228162514264 337593543950335 "
Sub DecimalAritmeti c()
Debug.Print d / CDec(5)
'15845632502852 867518708790067
End Sub
I have not run any kind of exhaustive testing of this at all.
Thanks Allen, et al, for the quick response and useful discussion. I
wasn't aware of (and the help files don't seem to mention) the liabilities
of the DECIMAL type. FLOAT should work fine for my needs. It would be
nice to be able to finely control the precision, but that can be handled
easily enough at the front end.
KC
Allen Browne wrote: Kevin Microsoft did not update DAO to support the creation of a DECIMAL field type. You need to execute your DDL query under ADO to create the table, e.g.:
strSql = "ALTER TABLE Table1 ADD COLUMN Field1 DECIMAL(10,2);" CurrentProject. Connection.Exec ute strSql
Personally, I consider it an advantage of DAO that it does not support this field type. JET has no idea how to handle it. Would you be happy if it could even handle as basic a query as this:
SELECT Field1 FROM Table1 ORDER BY Field1;
Details in: Incorrect Sorting (Decimal fields) at: http://allenbrowne.com/bug-08.html
No worries, Kevin.
BTW, Currency is a fixed point type: 4 places, but you can store the
fractions exactly.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Kevin Chambers" <My********@MyN ame.DontSpamMe. UncleSam> wrote in message
news:dq******** *@enews4.newsgu y.com... Thanks Allen, et al, for the quick response and useful discussion. I wasn't aware of (and the help files don't seem to mention) the liabilities of the DECIMAL type. FLOAT should work fine for my needs. It would be nice to be able to finely control the precision, but that can be handled easily enough at the front end.
KC
Allen Browne wrote: Kevin Microsoft did not update DAO to support the creation of a DECIMAL field type. You need to execute your DDL query under ADO to create the table, e.g.:
strSql = "ALTER TABLE Table1 ADD COLUMN Field1 DECIMAL(10,2);" CurrentProject. Connection.Exec ute strSql
Personally, I consider it an advantage of DAO that it does not support this field type. JET has no idea how to handle it. Would you be happy if it could even handle as basic a query as this:
SELECT Field1 FROM Table1 ORDER BY Field1;
Details in: Incorrect Sorting (Decimal fields) at: http://allenbrowne.com/bug-08.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Batista, Facundo |
last post by:
Here I send it.
Suggestions and all kinds of recomendations are more than welcomed.
If it all goes ok, it'll be a PEP when I finish writing/modifying the code.
Thank you.
.. Facundo
|
by: Blake T. Garretson |
last post by:
I'm having some issues with decimal.Decimal objects playing nice with
custom data types. I have my own matrix and rational classes which
implement __add__ and __radd__. They know what to do with Decimal
objects and react appropriately.
The problem is that they only work with Decimals if the custom type is
on the left (and therefore __add__ gets called), but NOT if the Decimal
is on the left. The Decimal immediately throws the usual...
|
by: John Bentley |
last post by:
John Bentley:
INTRO
The phrase "decimal number" within a programming context is ambiguous. It could
refer to the decimal datatype or the related but separate concept of a generic
decimal number. "Decimal Number" sometimes serves to distinguish Base 10
numbers, eg "15", from Base 2 numbers, Eg "1111". At other times "Decimal
Number" serves to differentiate a number from an integer. For the rest of this
post I shall only use either...
|
by: Artek |
last post by:
Hello,
after installing .net 1.1, ASP.NET works fine, but there is a problems with
extra zeros added to the numbers at the end.
In Sql 2000 SP3a there is for example a table with one column col1. Col1
is type of money ( four digits after decimal point).
Table has one row with data : col1=5.2.
In .Net 1.0 the following code
Response.Write("<input type=text size=3 maxlenght=4 name=test class=box
value='" + dt.DefaultView + "' >");
|
by: Ray |
last post by:
I have a table with some audit date and time columns. Problem is the
developer who stored the data left them as DECIMAL type instead of DATE
and TIME. Is there a way I can convert the DECIMAL type to DATE or
TIME? The column data is in the date form YYYYMMDD (i.e. 20060308 =
March 8 2006).
I want to get the data into a DATE type. I tried
TO_DATE('20060308','YYYYMMDD') but I cannot get it to work.
What else can I do to conver the data...
| |
by: Sam |
last post by:
I am trying to use a Simple form with 3 fields from SQL NorthWind
Database (Order Details Table with 3 Fields. - OrderId, ProductId and
Unit Price). The Field Unit Price has a data type of 'Money Type'.
All I want is to able to edit/view/insert 'UnitPrice' field with 2
decimal points instead of 4 decimal points.
If I use: Bind("UnitPrice", "{0:c}") in Edit Template, I got: "Input
string was not in a correct format...". Although this...
|
by: anilkmakhija |
last post by:
I need to store 256 bit hash (SHA-2 alogrithmn) in one of the table's
primary key. I would prefer to use numeric data type rather varchar
etc.
* Decimal datatype range is -10^38 +1 to 10^38 -1. I can split my 256
bit hash into two decimal(38, 0) type columns as composite key
* I can store the hash as varbinary. I never used it and don't have
much understanding in terms of query writing complexities and dealing
it through ADO (data type...
|
by: Lennart Benschop |
last post by:
Python has had the Decimal data type for some time now. The Decimal data
type is ideal for financial calculations. Using this data type would be
more intuitive to computer novices than float as its rounding behaviour
matches more closely what humans expect. More to the point: 0.1 and 0.01
are exact in Decimal and not exact in float.
Unfortunately it is not very easy to access the Decimal data type. To obtain
the decimal number 12.34 one...
|
by: =?Utf-8?B?UGFvbG8=?= |
last post by:
I have a table column of SQL smallmoney type which I am updating via a form
input field defined as decimal.
If I enter, say, 51.09 via the decimal input field (representing $51.09),
this is
displayed as 5109.0000 when I view the table data.
I'm not sure why 4 decimal places are being shown, and how would I get the
table data to represent the input i.e. 51.09? I don't want to have to divide
by 10,000
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |