472,986 Members | 2,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Change properties of existing tables without dataloss?

I have a lot of tables that hold a lot of numeric fields.
The names of all of these tables start with ' tblRO'
Now it turns out that all of the numeric fields with type double
precision have the property 'schaal' (<- dutch, the one above
'precision' ) set to zero. This should be '10' .

Is there a way to change this through VBA? Using a loop or so?
TIA Henro

Mar 22 '07 #1
3 2425
Excus me , I made an error!

I would like to know whether it is possible to change all the numeric
fields in certain tables to 'Decimal' type using code?
The decimal type has properties 'Precision' and 'Scale' (the latter
is a translated word from dutch which was 'schaal'.

I have to do this in 7 databases, 3 tables each, 14 fields
each..........
So I prefer some code that I can insert in a database and then run to
change the field properties.

Suggestions?

Greetings, Henro

On 22 mrt, 17:40, "Henrootje" <Hen...@gmail.comwrote:
I have a lot of tables that hold a lot of numeric fields.
The names of all of these tables start with ' tblRO'
Now it turns out that all of the numeric fields with type double
precision have the property 'schaal' (<- dutch, the one above
'precision' ) set to zero. This should be '10' .

Is there a way to change this through VBA? Using a loop or so?
TIA Henro

Mar 26 '07 #2
On Mar 26, 6:41 am, "Henrootje" <Hen...@gmail.comwrote:
I would like to know whether it is possible to change all the numeric
fields in certain tables to 'Decimal' type using code?
Before making such a wholesale change, look here:

http://allenbrowne.com/bug-08.html

Mar 26 '07 #3
On Mar 26, 7:16 pm, "Gord" <g...@kingston.netwrote:
I would like to know whether it is possible to change all the numeric
fields in certain tables to 'Decimal' type using code?

Before making such a wholesale change, look here:

http://allenbrowne.com/bug-08.html
I think the debate has moved on since that article was written and we
now seeing people recommending the DECIMAL data type.

Out of interest, do you agree with everything the articles says? I've
posted numerous rebuttals of the article in this groups which you
could google for. If you are genuinely interested in this subject then
perhaps we can discuss it further here. I hope you are not just
repeating something you've heard without checking the facts for
yourself first.

FWIW I've inadvertently made a misstatement on this topic which I'd
like to take this opportunity to correct:

http://groups.google.com/group/micro...45b50947e9839f

[quote]
>From "ADO Provider Properties and Settings"
(http://msdn.microsoft.com/library/de...library/en-us/
dnac...

"NULL Collation Order: A Long value (read-only) that specifies where
Null values are collated (sorted). For the Microsoft Jet provider,
the
value is always 4, which indicates that null values are sorted at the
low end of the list."

If there was a sort order bug with *any* Jet data type where the NULL
collation order was violated, it would be far more significant that
the
one under discussion that affects only negative DECIMAL values. Such
a
bug, should one exist, would almost certainly warrant a MSDN bug
article in itself. However, there is no such article and there is no
evidence I know of to suggest the NULL collation order is violated
under [any] circumstances.

[Unquote]

Actually, I think there is a problem where Jet NULL collation gets
violated. Consider that the essence of the DECIMAL sort order bug is
that the correctly-sorted set of negative values appear in the wrong
position of the resultset i.e. at the high end rather than between the
set of zeros and the set of NULLs at the low end. For example:

SELECT BadSort.dec_data
FROM
(
SELECT 3000000020 AS dec_data FROM DropMe
UNION ALL
SELECT NULL FROM DropMe
UNION ALL
SELECT -3000000010 FROM DropMe
UNION ALL
SELECT 0 FROM DropMe
UNION ALL
SELECT 3000000005 FROM DropMe
UNION ALL
SELECT -3000000005 FROM DropMe
UNION ALL
SELECT 0 FROM DropMe
UNION ALL
SELECT 3000000010 FROM DropMe
UNION ALL
SELECT NULL FROM DropMe
UNION ALL
SELECT -3000000020 FROM DropMe
) AS BadSort
ORDER BY BadSort.dec_data DESC;

So the trick would appear to be to force the set of zeros and positive
numbers to appear first and I've seen this posted as a suggested
solution:

ORDER BY BadSort.dec_data >= 0, BadSort.dec_data DESC;

However, this causes the NULL values to appear at the high end of the
resultset! The same problem is also exhibited by data types other than
DECIMAL.

So Jet's NULL collation has been violated and it does not seem to have
been big news. Guess I was wrong about that, then :(

I suspect the behaviour is due to known issues with the Jet's YESNO
data type which doesn't fit well with SQL's three-value logic (Jet
would appear to treat an UNKNOWN logical result differently than a
NULL value). The problem can be corrected, of course, in the ORDER BY
clause by removing the possibility of an UNKNOWN result by explicitly
handling NULL e.g.

ORDER BY BadSort.dec_data >= 0 AND BadSort.dec_data IS NOT NULL,
BadSort.dec_data DESC;

I suspect, though, that such an expression in the ORDER BY clause
would not perform well. My feeling is that the most *efficient* way to
sort would be to cast as DOUBLE, assuming that limiting scale to 15
significant figures is acceptable e.g.

ORDER BY CDBL(BadSort.dec_data DESC;

Interestingly, Allen condemns this as "very inefficient, requiring
conversion at every row" but I don't think that is correct: Jet has a
very efficient means of promoting a column of data to a higher type,
including promoting DECIMAL to DOUBLE.

All that said, I rarely if ever need to sort a resultset into an
explicit order in SQL (being a set-based language; sets have no
inherent order) and sorting in the middleware (e.g. recordset.Sort)
sidesteps the engine's problem with sorting.

PS I would also like to point out that Allen has said Access 2007 "is
too buggy for serious use" (http://allenbrowne.com/Access2007.html) so
I trust you will remind people of that at every mention of anything
Access 2007 related ;-)

Jamie.

--

Mar 27 '07 #4

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

Similar topics

5
by: Robert Stearns | last post by:
Either I missed something, or ALTER TABLE does not have this capability. Is there any way of doing it except DROPping all constraints which mention this table, EXPORTing the data, DROPping the...
1
by: Richard Holliingsworth | last post by:
Hello: The group has new 'standards' for online forms and I need to change the 'style' of my existing forms (A2002). Can I do this? I can't find a way using the GUI or the properties. ...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
3
by: sparks | last post by:
I was copying fields from one table to another. IF the var name starts with milk I change it to egg and create it in the destination table. It works fine but I want to copy the description as...
2
by: Dennis Ruppert | last post by:
I created a routine to read and edit the description properties of tables, (the one you see in the database window). It works just fine. This is the basic code behind it, I substituted all my...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
13
by: nyt | last post by:
I have a problem of number and text field. I got the database file(mdb) that contains many combo boxes used and its list values are created by "value list" For eg field Field name= 'furniture'...
5
by: Dmitriy Lapko | last post by:
Hallo all Is it possible to change schema of table in DB2 v.8.2 without recreating and coping a table into a new schema? I need it for several purposes, one of them - refactoring of existing...
1
by: thesti | last post by:
hi, i'm going to develop a program using VB .NET. i've bound some textboxes to the same DataSource (DataSet1.Tables(0). and i enable the user to type the primaryKey of the data in the Table,...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.