473,465 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I get min max from 100 cuts in one record?

We have a precision cut database that measures the cut width. We set the
database up with 100 fields (one for each possible cut). Some of the fields
are going to be Null. We need to analyze the record to find the min and max,
average, and statistical deviation. Is there a way to do this in Access 97?
I see all kinds of examples for record by record but nothing within a single
record.

My fields start with
Cut1
Cut2, etc.

It wasn't the best way to set the database up but since it was inherited I
wonder if anyone can help me salvage this.
Jul 11 '06 #1
5 1206

Robert Waggoner wrote:
We have a precision cut database that measures the cut width. We set the
database up with 100 fields (one for each possible cut). Some of the fields
are going to be Null. We need to analyze the record to find the min and max,
average, and statistical deviation. Is there a way to do this in Access 97?
I see all kinds of examples for record by record but nothing within a single
record.

My fields start with
Cut1
Cut2, etc.

It wasn't the best way to set the database up but since it was inherited I
wonder if anyone can help me salvage this.
I'd probably normalize to a new table and then summarize that.
Otherwise, you're going to have a horrendous time trying to get the
data together. You can use DAO to get data nd fieldnames and then use
some basic logic to flatten to something like (MeasurementType,
Measurement). then you can do stats on that.

Jul 11 '06 #2
Thanks! But I'm not sure how to write the code to create the new table. Any
help getting started would be appreciated.
<pi********@hotmail.comwrote in message
news:11**********************@s13g2000cwa.googlegr oups.com...
>
Robert Waggoner wrote:
>We have a precision cut database that measures the cut width. We set the
database up with 100 fields (one for each possible cut). Some of the
fields
are going to be Null. We need to analyze the record to find the min and
max,
average, and statistical deviation. Is there a way to do this in Access
97?
I see all kinds of examples for record by record but nothing within a
single
record.

My fields start with
Cut1
Cut2, etc.

It wasn't the best way to set the database up but since it was inherited
I
wonder if anyone can help me salvage this.

I'd probably normalize to a new table and then summarize that.
Otherwise, you're going to have a horrendous time trying to get the
data together. You can use DAO to get data nd fieldnames and then use
some basic logic to flatten to something like (MeasurementType,
Measurement). then you can do stats on that.

Jul 11 '06 #3

Robert Waggoner wrote:
Thanks! But I'm not sure how to write the code to create the new table. Any
help getting started would be appreciated.
Creating the table isn't the problem.

Something like
CutID
CutType
CutValue

"CutType" would correspond to your column name in your current table.
"CutValue" would correspond to the number/value in the non-null field.

The way I would go about solving it is creating and executing a series
of SQL statements in code that select the non-null value "pairs" and
then inserting them into a normalized table using CurrentDB.Execute
<SQL statement>. Then the code would switch the fields and you'd be
done in no time.

This is what I've come up with so far...

<Note to serious developers... put the coffee down, finish
swallowing... I don't want to be responsible for hot-beverage-related
mishaps.

'----CODE START------------------
Option Compare Database

Public Sub NormalizeData()

Dim tdf As DAO.TableDef
Dim strFieldName As String
Dim intCounter As Integer

Const cSQL As String = "INSERT INTO tblCutsFinal (ID, MyValue,
MyFieldName) SELECT tblNonNormalCuts.MyID,"
Dim strSQL As String

Set tdf = DBEngine(0)(0).TableDefs("tblNonNormalCuts")

'---Loop through the field pairs fields(0) and fields(intCounter),
'--- and append them to the final table

For intCounter = 1 To tdf.Fields.Count - 1

'-----Build Insert statement

strSQL = cSQL & "[" & tdf.Name & "].[" &
tdf.Fields(intCounter).Name & "],'" & tdf.Fields(intCounter).Name & "'
FROM [" & tdf.Name & "] "
strSQL = strSQL & "WHERE ((([" & tdf.Name & "].[" &
tdf.Fields(intCounter).Name & "] IS NOT NULL)));"
'----Execute it
DBEngine(0)(0).Execute strSQL, dbFailOnError
Next intCounter

Set tdf = Nothing

End Sub

'----CODE END...

Jul 12 '06 #4
Hi Robert,

With all due respect, your data is classic of a non normalized table.
The issue here is that it becomes way more difficult to perform sql
operations on non-normalized tables. A non-normalized table is a table
that contains redundant columns. Based on your description, your table
should only have 2 columns (3 columns if you want to include an autonum
column)

cutType CutWidth
cut1 .5
cut2 .7
cut3 3
cut4 .6
cut5 16
...
cut100 4.6

Now you can use the sql functions from an Access query very easily to
perform calculations on the widths.

Access can manage 100,000 rows way easier than 100 columns. The reason
you have not found any examples on how to use sql agains columns is
because sql is designed to be used against rows.

If you plan on using your DB in production, you (or someone) need to
normalize it first. Even if that is a big hassle, as you can see,
dealing with an non-normalized DB is a bigger hassel.

HTh

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jul 12 '06 #5
Thank you! I'll begin testing this today.
<pi********@hotmail.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
>
Robert Waggoner wrote:
>Thanks! But I'm not sure how to write the code to create the new table.
Any
help getting started would be appreciated.

Creating the table isn't the problem.

Something like
CutID
CutType
CutValue

"CutType" would correspond to your column name in your current table.
"CutValue" would correspond to the number/value in the non-null field.

The way I would go about solving it is creating and executing a series
of SQL statements in code that select the non-null value "pairs" and
then inserting them into a normalized table using CurrentDB.Execute
<SQL statement>. Then the code would switch the fields and you'd be
done in no time.

This is what I've come up with so far...

<Note to serious developers... put the coffee down, finish
swallowing... I don't want to be responsible for hot-beverage-related
mishaps.

'----CODE START------------------
Option Compare Database

Public Sub NormalizeData()

Dim tdf As DAO.TableDef
Dim strFieldName As String
Dim intCounter As Integer

Const cSQL As String = "INSERT INTO tblCutsFinal (ID, MyValue,
MyFieldName) SELECT tblNonNormalCuts.MyID,"
Dim strSQL As String

Set tdf = DBEngine(0)(0).TableDefs("tblNonNormalCuts")

'---Loop through the field pairs fields(0) and fields(intCounter),
'--- and append them to the final table

For intCounter = 1 To tdf.Fields.Count - 1

'-----Build Insert statement

strSQL = cSQL & "[" & tdf.Name & "].[" &
tdf.Fields(intCounter).Name & "],'" & tdf.Fields(intCounter).Name & "'
FROM [" & tdf.Name & "] "
strSQL = strSQL & "WHERE ((([" & tdf.Name & "].[" &
tdf.Fields(intCounter).Name & "] IS NOT NULL)));"
'----Execute it
DBEngine(0)(0).Execute strSQL, dbFailOnError
Next intCounter

Set tdf = Nothing

End Sub

'----CODE END...

Jul 13 '06 #6

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

Similar topics

15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: Scott269 | last post by:
So I've got an old MS Works database I imported into Access. I needed a primary key so I created a record number field that was just the record number I manually inserted when I entered it in the...
2
by: Mark Reed | last post by:
Hi All, I have created a multi-user application at work which is working perfectly apart from a small problem which I believe to more a of a user issue (maybe some will set me straight on that...
11
khalidbaloch
by: khalidbaloch | last post by:
hi : all Friend i am a new member of this comunity as well in php myqsl i want learn that how to dispaly three or two record from a mysql table for example .. mysql table category has 21 columns,...
3
prn
by: prn | last post by:
Hi folks, I've got something that's driving me crazy here. If you don't want to read a long explanation, this is not the post for you. My problematic Access app is a DB for keeping track of...
4
by: trint | last post by:
I am developing a new website for our company with c# dotNet. There is no problem displaying this website with ie6. Last week I downloaded ie7 because a friend of mine said he could only see half...
0
by: service0059 | last post by:
This category is designed to enable you to have all the important information right at your fingertips and create better "sight value". You will learn how karat gold affects appeal and value and...
1
by: Seth Williams | last post by:
I've got a strange problem - - I've got an input form (members), which has standard data, name, address, phone, etc I've changed the table now, so that the phone number accepts a varchar(25) - I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.