473,396 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Table decimal places

Hello,

I'm running Access 2000. I would like to know if its
possible to use VBA code to determine how many decimal places are
specified for each table field.

Currently I loop throught the Tables Collection, the Tables
Fields Collection, and then the Field Properties Collection but I do
not see what I need. I don't want to change the setting. I just want
to make a list of the decimal place setting for each "Single" field in
all Tables.

Thanks,
Hank Reed

Aug 18 '06 #1
4 6918
"Hank" <ha********@aol.comwrote in message
<11**********************@h48g2000cwc.googlegroups .com>:
Hello,

I'm running Access 2000. I would like to know if its
possible to use VBA code to determine how many decimal places are
specified for each table field.

Currently I loop throught the Tables Collection, the Tables
Fields Collection, and then the Field Properties Collection but I do
not see what I need. I don't want to change the setting. I just want
to make a list of the decimal place setting for each "Single" field
in all Tables.

Thanks,
Hank Reed
Doesn't the DecimalPlaces property give that?

Dim td As DAO.TableDef
Dim db As DAO.Database
Dim fd As DAO.Field
Set db = DBEngine(0)(0)
For Each td In db.TableDefs
For Each fd In td.Fields
If fd.Type = dbSingle Then
Debug.Print td.Name, fd.Name, _
fd.Properties("DecimalPlaces").Value
End If
Next fd
Next td

--
Roy-Vidar
Aug 18 '06 #2
Doesn't the DecimalPlaces property give that?
>
Dim td As DAO.TableDef
Dim db As DAO.Database
Dim fd As DAO.Field
Set db = DBEngine(0)(0)
For Each td In db.TableDefs
For Each fd In td.Fields
If fd.Type = dbSingle Then
Debug.Print td.Name, fd.Name, _
fd.Properties("DecimalPlaces").Value
End If
Next fd
Next td

--
Roy-Vidar
Roy,
I tried your function and got "Property Not Found" for the
"DecimalPlaces" property. Actually it didn't recognize "Caption" or
other properties I thought should be there. I tried listing the
properties and found out that "DecimalPlaces" was number 23 but could
not get the value. I tried using fd.Properties(1) - (25) and got
values up to (8) but it would not recognize (9) and up.
As a test, I added a new table with singles in it and your
function reads it just fine. I tried to characterize the other tables
to see what the difference was but I could not find anything
significant.
Any ideas?
Hank

Aug 20 '06 #3
"Hank" <ha********@aol.comwrote in message
<11*********************@i3g2000cwc.googlegroups.c om>:
>Doesn't the DecimalPlaces property give that?

Dim td As DAO.TableDef
Dim db As DAO.Database
Dim fd As DAO.Field
Set db = DBEngine(0)(0)
For Each td In db.TableDefs
For Each fd In td.Fields
If fd.Type = dbSingle Then
Debug.Print td.Name, fd.Name, _
fd.Properties("DecimalPlaces").Value
End If
Next fd
Next td

--
Roy-Vidar

Roy,
I tried your function and got "Property Not Found" for the
"DecimalPlaces" property. Actually it didn't recognize "Caption" or
other properties I thought should be there. I tried listing the
properties and found out that "DecimalPlaces" was number 23 but could
not get the value. I tried using fd.Properties(1) - (25) and got
values up to (8) but it would not recognize (9) and up.
As a test, I added a new table with singles in it and your
function reads it just fine. I tried to characterize the other
tables to see what the difference was but I could not find anything
significant.
Any ideas?
Hank
Some properties, like the Caption property, doesn't exist until they
are
set or created, either through the interface, or programatically. So,
those fields where you haven't set any caption, will return a 3270 -
property not found error.

For the Decimal Places property, it is a bit different. I think that if
you create the table through design view in Access, the property is set
regardless of whether you actually alter the value there or not. If you
on the other hand create the table through DDL, then it's not.

I don't work with these properties much programatically, but I think
that if your purpose is to just list the property values, I think that
you can safely assume that 3270 for the caption property, means no
caption is set, and for Decimal Places property for double/single
fields, then it's the default "Auto".

If you use on error resume next, and check for err.number = 3270, then
you should be able to determine which properties exists or not.

--
Roy-Vidar
Aug 20 '06 #4
Some properties, like the Caption property, doesn't exist until they
are
set or created, either through the interface, or programatically. So,
those fields where you haven't set any caption, will return a 3270 -
property not found error.

For the Decimal Places property, it is a bit different. I think that if
you create the table through design view in Access, the property is set
regardless of whether you actually alter the value there or not. If you
on the other hand create the table through DDL, then it's not.

I don't work with these properties much programatically, but I think
that if your purpose is to just list the property values, I think that
you can safely assume that 3270 for the caption property, means no
caption is set, and for Decimal Places property for double/single
fields, then it's the default "Auto".

If you use on error resume next, and check for err.number = 3270, then
you should be able to determine which properties exists or not.

--
Roy-Vidar
Roy,
The Caption field wasn't really important to me. I was just
casting about to find anything that could be read. This exercise is
part of my migration to a Postgres database and I wanted a list of
Decimal Places on the Access side so the Postgres tables could be
created properly.
When I was having the problem reading the decimal places, I
was inadvertently linked to the Postgres tables (Dumb). Everything
works now.
Thanks for staying with this.
Hank

Aug 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
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....
3
by: Brent Bortnick | last post by:
Does anyone know how to find out the number of decimal places a number has. I need this info so that i can round to 3 decimal places if the number has 3 decimal places or to 2 decimal places if...
2
by: Carl G | last post by:
I am storing a 0.000 a System.Decimal in a DataRow. On retrieval the value is only 0 without the three decimal places. It looks like the Get property returns System.Decimal.Zero, but why???? I...
4
by: Laphan | last post by:
Hi All Wonder if you could help, I have a bog standard table called STOCKPRICES that has served me well for a while, but now I need to change the structure of it and because a number of users...
4
by: italia | last post by:
I changed the Fieldsize Property from text to Long Integer and Decimal Places = 6. I had decimals in the original field. But after the transfer, the digits after the decimals are gone. Now...
8
by: nick | last post by:
printf("%lf",3.25); the result is 3.25000 i want the answer correct to 3 decimal places What should i do? thanks!
9
by: NEWSGROUPS | last post by:
I have data in a table in an Access 2000 database that needs to be exported to a formatted text file. For instance, the first field is an account number that is formatted in the table as text and...
9
by: =?Utf-8?B?TWlrZTk5MDA=?= | last post by:
I save a number in the table and want to get that number again, but the number I get has lower precision than I expect. For example, when I divide 10/3 I get 3.3333333333333335 if the variable is...
4
by: grego9 | last post by:
I have two tables that are linked by a common field called 'reference'. i am running a query and want the query to post a text of "EXCHANGE OV CHANGE" against each record where a field called "ORIG...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.