473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6934
"Hank" <ha********@aol .comwrote in message
<11************ **********@h48g 2000cwc.googleg roups.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
"DecimalPla ces" property. Actually it didn't recognize "Caption" or
other properties I thought should be there. I tried listing the
properties and found out that "DecimalPla ces" 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************ *********@i3g20 00cwc.googlegro ups.com>:
>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
"DecimalPla ces" property. Actually it didn't recognize "Caption" or
other properties I thought should be there. I tried listing the
properties and found out that "DecimalPla ces" 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
6117
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...
3
7068
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 the number has 2 decimal places. Any help would be great. Regards, Brent
2
3585
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 can't figure out why the design is so that the DataRow "alters" the value entered. In my application a decimal column in a row of a specific table...
4
3249
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 have used it in it's present form I need to so the following in SQL script: a) Grab a snapshot of the current SQL data. b) Re-structure the...
4
9719
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 even after I have change the Fieldsize propert to Decimal with Scale = 2, the digits after the decimal are not seen. For eg. If the text was 16.27....
8
11320
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
7688
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 is 8 characters long. This field needs to be exported as pic(15) padded in the front with 0's (zeros). The next field an ID name that is 15...
9
1644
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 of type Double. But saving this result into a table with a column of type Double decreases the precision to 3.333333333333333 , so when I get this...
4
5174
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 Value", present in both tables, differs by reference number Expr2: IIf(!<>!,"EXCHANGE OV CHANGE","NOT EX") The BG Last AP table is linked from...
0
7697
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
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...
0
7924
Oralloy
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. ...
0
8120
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6283
agi2029
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...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
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...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
937
bsmnconsultancy
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...

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.