473,385 Members | 1,925 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,385 software developers and data experts.

Counting scores

I produce a query that looks like this -

FieldA FieldB FieldC FieldD FieldE FieldF FieldG FieldH
4 5 4 3 4 5 3 4
4 4 4 4 4 4 4 5
5 5 5 5 4 4 4 3
3 4 4 4 3 4 5 4

How can I produce a table which finds out how many 1s, 2s, 3s, 4s & 5s there are in each column?

Result would look like this -
Number FieldA FieldB FieldC FieldD FieldE FieldF FieldG FieldH
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 1 0 0 1 1 0 1 1
4 2 2 3 2 3 3 2 2
5 1 2 1 1 0 1 1 1
Sep 29 '06 #1
3 1417
PEB
1,418 Expert 1GB
Hi,

You can do it...

All You need is a temporary table with one column - mynumber where to store your numbers from 1 to 5 i.e

and the function dcount

Invoke a new query based on the temporary table!

For exemple

FieldA in your table will be:

Dcount("FieldA","YourQuery","FieldA="+Str(mynumber ))

And so on...

:)

Best regards!
Sep 30 '06 #2
Hi,

You can do it...

All You need is a temporary table with one column - mynumber where to store your numbers from 1 to 5 i.e

and the function dcount

Invoke a new query based on the temporary table!

For exemple

FieldA in your table will be:

Dcount("FieldA","YourQuery","FieldA="+Str(mynumber ))

And so on...

:)

Best regards!

Thanks for your help - I'm almost there but now have some very clumsy code which I'm sure someone can help me turn into a do loop. I haven't done much with VBA and my attempts have failed so far.

My code is as follows and uses T-input for now rather than a query as the real thing will and my counts are stored in T-stats

' Count how many values in T-input= 1 and store in T-stats row 1
mySQL = "UPDATE [T-stats]"
mySQL = mySQL + " SET [T-stats]!FieldAcount = (DCount('([T-input].FieldA)', '[T-input]', '[T-input]!FieldA = 1')) "
mySQL = mySQL + " WHERE (([T-stats]![Score] = 1)) "
DoCmd.RunSQL mySQL
mySQL = "UPDATE [T-stats]"
mySQL = mySQL + " SET [T-stats]!FieldBcount = (DCount('([T-input].FieldB)', '[T-input]', '[T-input]!FieldB = 1')) "
mySQL = mySQL + " WHERE (([T-stats]![Score] = 1)) "
DoCmd.RunSQL mySQL
mySQL = "UPDATE [T-stats]"
mySQL = mySQL + " SET [T-stats]!FieldCcount = (DCount('([T-input].FieldC)', '[T-input]', '[T-input]!FieldC = 1')) "
mySQL = mySQL + " WHERE (([T-stats]![Score] = 1)) "
DoCmd.RunSQL mySQL
mySQL = "UPDATE [T-stats]"
mySQL = mySQL + " SET [T-stats]!FieldDcount = (DCount('([T-input].FieldD)', '[T-input]', '[T-input]!FieldD = 1')) "
mySQL = mySQL + " WHERE (([T-stats]![Score] = 1)) "
DoCmd.RunSQL mySQL
mySQL = "UPDATE [T-stats]"
mySQL = mySQL + " SET [T-stats]!FieldEcount = (DCount('([T-input].FieldE)', '[T-input]', '[T-input]!FieldE = 1')) "
mySQL = mySQL + " WHERE (([T-stats]![Score] = 1)) "
DoCmd.RunSQL mySQL

How do I replace everywhere that uses 1 with "mynumber" so that I can loop through with mynumber increasing from 1 to 5 instead of writing the above out 5 times over?

Kind regards

palacefan
Oct 2 '06 #3
Thanks for your extra instructions - it now makes sense and works brilliantly. Your help was much appreciated.

palacefan
Oct 9 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lord Merlin | last post by:
How do I add up the values of the data from all of the rows returned? i.e - I have a DB, with 148 rows of client info, and I want to addup all the scores. Each entry's score differes. Here is the...
3
by: Irene | last post by:
Hi all, I have set up a simple VB program (and later on an ASP interface) to manage an Athletics database. I'm using Access 2000. To simplify, I have the Athlets, the Competitions and the...
1
by: John Brajkovich | last post by:
I have 10 tables that are identical in structure. They contain a location code, an employee id for that location and a score. In all of these tables a location code/employee id combanation uniquely...
11
by: Penfold | last post by:
I'd appreciate help converting student average test scores into grades. My problem is that I need to allocate one of about 20 grades (3a,3b,3c,4a,4b,4c etc through to 8c plus a couple of others)....
1
by: waldoruns | last post by:
I need help to finish this code.....Here is what I got so far...... /Read in test scores and output total number of scores, total number of each letter grade, //percentage of total for each...
0
by: asrock | last post by:
i have prepared a code in c++ to save high scores and it is working well when i compile it in turbo c++and run the code . but when i exit from the turbo c++ , the file to which i saved the high...
3
by: Akinyemi | last post by:
I am writing a Visual Basic program for calculating students scores, and also grading the highest 3 scores as "First" , "Second" and "Third" respectively. I have been able to get the program to...
4
by: jocknerd | last post by:
About 10 years ago, I wrote a C app that would read scores from football games and calculate rankings based on the outcome of the games. In fact, I still use this app. You can view my rankings at...
0
by: Racqetsports | last post by:
Hi there, In a gradebook database, student grades must be computed from 2 scores: a Daily grade, and then scores from Assignments. Knowing about nested forms, I am requesting direction on how to...
8
by: d24706 | last post by:
Hello, I hope someone can help me. I had to do the following assignment( i have most of it done just cant finish it off, question and source code below). Question? Write a Java program that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.