PC Review


Reply
Thread Tools Rate Thread

Change Precision and Scale

 
 
Jay
Guest
Posts: n/a
 
      8th Jul 2009

Access version: 2007

Is there a way to change the Precision property of a Decimal field using VBA
code? I have tried
myTableDef.Field(FieldNum).Properties("CollatingOrder") = 13
and
myRecordSet.Field(FieldNum).Properties("CollatingOrder") = 13
but both give an "Invalid arguement" error.

I have also tried using an ADO recordset:
rs.Fields("DField").Precision = 13
In this case, no errors are thrown and the property is changed, but when I
close the connection and open the table in design view in Access, the
precision hasn't changed.

I also tried an SQL
ALTER TABLE tablename ALTER COLUMN columname DECIMAL (13,6)
statement, but it gives a syntax error. According to the access help file,
only text and binary fields can take a (size) parameter.

Jay
 
Reply With Quote
 
 
 
 
Jay
Guest
Posts: n/a
 
      9th Jul 2009

I found a solution using ADO (from another forum):

Dim cs As ADODB.Connection
Set cs = New ADODB.Connection
cs.ConnectionString =
Replace(CurrentProject.Connection.ConnectionString, "BugAndFeatures.accdb",
"testdecimal.accdb")
cs.Open
cs.Execute "ALTER TABLE TestDecimalTable ALTER COLUMN DField DECIMAL
(13,6);"
cs.Close

Jay


"Jay" wrote:

> Access version: 2007
>
> Is there a way to change the Precision property of a Decimal field using VBA
> code? I have tried
> myTableDef.Field(FieldNum).Properties("CollatingOrder") = 13
> and
> myRecordSet.Field(FieldNum).Properties("CollatingOrder") = 13
> but both give an "Invalid arguement" error.
>
> I have also tried using an ADO recordset:
> rs.Fields("DField").Precision = 13
> In this case, no errors are thrown and the property is changed, but when I
> close the connection and open the table in design view in Access, the
> precision hasn't changed.
>
> I also tried an SQL
> ALTER TABLE tablename ALTER COLUMN columname DECIMAL (13,6)
> statement, but it gives a syntax error. According to the access help file,
> only text and binary fields can take a (size) parameter.
>
> Jay

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Change rounding precision from .5 to .25 sBlack Microsoft Excel Worksheet Functions 1 9th Oct 2008 09:56 PM
Specifying Precision and Scale for SQLDecimal in User Defined CLR SQL Server Function Crazy Cat Microsoft VB .NET 0 24th Mar 2006 05:04 PM
Specifying Precision and Scale for SQLDecimal in User Defined CLR SQL Server Function Crazy Cat Microsoft VB .NET 0 24th Mar 2006 05:01 PM
Decimal precision of change history? Dmitry Bogdanov Microsoft Excel Misc 0 28th Feb 2006 10:36 AM
Can I change the precision of Excel calculations Chris Microsoft Excel Misc 2 12th Aug 2003 08:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:45 AM.