Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 21st, 2006, 12:55 PM
minjie@excite.com
Guest
 
Posts: n/a
Default How to create a decimal number in Access?

When I executed the following in Access:

alter table t1 alter column c1 decimal(8,4);

I got an error message: "Syntax error in ALTER TABLE statement". I got
a similar error when I tried to add a decimal field. I know I can
define a DECIMAL data type via Access GUI interface. But isn't there a
way to do it directly with a SQL statement?

Thanks.

  #2  
Old February 21st, 2006, 02:45 PM
summerwind
Guest
 
Posts: n/a
Default Re: How to create a decimal number in Access?

I couldn't find a reference to ALTER TABLE in ADO or DAO

I think you need to use ADOX to add columns and change attributes of a
table.


minjie@excite.com wrote:[color=blue]
> When I executed the following in Access:
>
> alter table t1 alter column c1 decimal(8,4);
>
> I got an error message: "Syntax error in ALTER TABLE statement". I got
> a similar error when I tried to add a decimal field. I know I can
> define a DECIMAL data type via Access GUI interface. But isn't there a
> way to do it directly with a SQL statement?
>
> Thanks.[/color]

  #3  
Old February 21st, 2006, 03:05 PM
Lyle Fairfield
Guest
 
Posts: n/a
Default Re: How to create a decimal number in Access?

from help

"A new Microsoft Jet 4.0 data type
Decimal data types are new to Microsoft Jet 4.0. It is an exact numeric
data type that holds values from -10^28 - 1 through 10^28 - 1. You can
define both precision (1 - 28) and scale (0 - defined precision). The
default precision and scale are 18 and 0, respectively. Supported
synonyms are Dec and Numeric. Data accessed via ODBC that is typed as
Sql_Decimal or Sql_Numeric will now be mapped to the Microsoft Jet
Decimal, instead of Currency. This data type is not supported via Data
Access Objects (DAO). It is supported only with ActiveX Data Objects
(ADO)."

Thus - CurrentProject.Connection.Execute "ALTER TABLE TableName ALTER
COLUMN ColumnName Decimal (28,9)"

You chould be aware that there are sorting problems with this data
type; solvable in some people's minds, not solvable in others; an index
on the field seems to clear up most of these.

  #4  
Old February 21st, 2006, 08:05 PM
minjie@excite.com
Guest
 
Posts: n/a
Default Re: How to create a decimal number in Access?


Lyle Fairfield wrote:[color=blue]
> from help
>
> "A new Microsoft Jet 4.0 data type
> Decimal data types are new to Microsoft Jet 4.0. It is an exact numeric
> data type that holds values from -10^28 - 1 through 10^28 - 1. You can
> define both precision (1 - 28) and scale (0 - defined precision). The
> default precision and scale are 18 and 0, respectively. Supported
> synonyms are Dec and Numeric. Data accessed via ODBC that is typed as
> Sql_Decimal or Sql_Numeric will now be mapped to the Microsoft Jet
> Decimal, instead of Currency. This data type is not supported via Data
> Access Objects (DAO). It is supported only with ActiveX Data Objects
> (ADO)."
>
> Thus - CurrentProject.Connection.Execute "ALTER TABLE TableName ALTER
> COLUMN ColumnName Decimal (28,9)"
>
> You chould be aware that there are sorting problems with this data
> type; solvable in some people's minds, not solvable in others; an index
> on the field seems to clear up most of these.[/color]

Thanks a lot!

 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles