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

Help with average and percentage calculation from a query

I am using Access 2003. I am setting up a form where a user selects a Clinic or Ward, beginning date, and ending date, and the form outputs the averages of a few fields based on that criteria. I have come up with this so far for the query -

Dim strSQL As String
strSQL = ""
If chkClinic.Value = -1 Then
strSQL = "Select avg(Courtesy), avg(Timeliness), avg(Confidence), avg(Privacy), " & _
"avg(Sensitivity), avg(Cleanliness), avg(Advice), avg(Overall) FROM tblScores " & _
"WHERE Clinic = '" & Me!cboClinic.Value & "' AND Date >= " & Me!txtBegin.Value & _
" AND Date <+ " & Me!txtEnd.Value
Else
strSQL = "Select avg(Courtesy), avg(Timeliness), avg(Confidence), avg(Privacy), " & _
"avg(Sensitivity), avg(Cleanliness), avg(Advice), avg(Overall) FROM tblScores " & _
"WHERE Ward = '" & Me!cboWard.Value & "' AND Date >= " & Me!txtBegin.Value & _
" AND Date <+ " & Me!txtEnd.Value
End If

But I'm having trouble getting the data pulled from that query into the proper text boxes (txtCourtesy, txtTimeliness, etc.). I've been pulling it into a recordset but I can't seem to get anything to work right. I think I just don't really have a grasp on how to manipulate a recordset yet.

Also - there is another category, "Handwashing," in addition to these others. Whereas the other factors are on a 0-5 scale, so an average works fine, Handwashing is boolean. I would like to calculate Handwashing so that the query returns a percentage of numerator "true" and denominator of total records. I imagine I'll be able to do this part pretty easily once I figure out the other part.
Sep 17 '07 #1
1 1619
FishVal
2,653 Expert 2GB
Hi, there.

When you run SELECT query with calculated fields. The latter are being returned with default field names - like ExprXXXX. Do you refer them by this names?
If you want to explicitely set the name of calculated field, then use "AS" keyword.
e.g.
Expand|Select|Wrap|Line Numbers
  1. SELECT Avg([FieldName]) AS AvgFieldName FROM [tblTable];
  2.  
Sep 17 '07 #2

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

Similar topics

4
by: Norma | last post by:
I am posting this again since I am on a deadline to get this completed... Sorry for being redundant... I have a table with a UPC#, CasesCompleted, TotalHours, standardGoal (pieces per hour) I...
4
by: Terencetrent | last post by:
I having been using Access '97/2002 for about 4 years now and have never really had the need or the time to learn visual basic. Well, I think the time has finally come. I need help with Visual...
2
by: cowboyboborton | last post by:
Looking for some help here. I've tried to solve this, but I just can't. What I need to know is what formula to use in an excel calculation to complete the following calculation. It's in two...
13
by: Fao | last post by:
Hello, I am having some problems with inheritance. The compiler does not not return any error messages, but when I execute the program, it only allows me to enter the number, but nothing else...
11
by: Kush | last post by:
Hello All, I am having problem writing some data to file and I do not understand my mistake / misconception. I am trying to write some simple text to file but the text is rather output to...
9
by: wparrott | last post by:
I have a table called tblPayScales. It has 5 fields: numRecID - record ID txtCLASSCODE - a 1 or 2 letter text value (A, B, C, BD, L, LT, etc.) numPAYSTEP - a number value 0-49 numSALARY - a...
1
by: ABHICA2004 | last post by:
Presently I'm dealing with a data base with the structure as under: 1.Source document is an excel file which contains thousands of rows ( item)& multiple columns ( relating to each individual...
2
by: patrickahutah | last post by:
I need some help on computing this formula especially the best way to capture the data that is whether to use excel or ms access, then with the data compute the formula. The excercise is for bonus...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.