473,791 Members | 2,949 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loop through table, Count occurrences, send to report

2 New Member
I am working with Access 2000, on Windows XP (all updates).

I designed a survey in Word with 150+ questions. Roughly 60 questions use a lookup list of 7 different responses.
I have the survey broken up into sections with each question numbered. As a test, I created a Survey database and chose one section of 10 questions and created a table that looks like this:

ID Q1 Q2 Q3...Q10
1 3 4 7... 2

ID will link to personal info, and other question tables.

I used a lookup table for the 7 possible responses.

I want to loop through my table working through each question so that I can count the number of times a particular response is made. Then I want to calculate the percentage from the total number of participants for that question.

I would like to either output the data into another table or a report, (whichever is easier) sort of like this:

Q1 1 30 ?%
2 8 ?%
3 0 ?%
and so on through 7. I would need to do this for each question.

I was thinking of something like:

Do until EOF
Loop through each record, column by column
compare response with lookup list
Count (IIf([response}="1",0 ) (would a Switch work here for all 7 responses?)
Print this to table
percent=Count of particular response/total participants*10 0.
Print this to table.

Can anyone help? I am not sure if this should be a UDF or ???.

Thank you in advance, Carolyn
Oct 25 '07 #1
1 4206
nico5038
3,080 Recognized Expert Specialist
I am working with Access 2000, on Windows XP (all updates).

I designed a survey in Word with 150+ questions. Roughly 60 questions use a lookup list of 7 different responses.
I have the survey broken up into sections with each question numbered. As a test, I created a Survey database and chose one section of 10 questions and created a table that looks like this:

ID Q1 Q2 Q3...Q10
1 3 4 7... 2

ID will link to personal info, and other question tables.

I used a lookup table for the 7 possible responses.

I want to loop through my table working through each question so that I can count the number of times a particular response is made. Then I want to calculate the percentage from the total number of participants for that question.

I would like to either output the data into another table or a report, (whichever is easier) sort of like this:

Q1 1 30 ?%
2 8 ?%
3 0 ?%
and so on through 7. I would need to do this for each question.

I was thinking of something like:

Do until EOF
Loop through each record, column by column
compare response with lookup list
Count (IIf([response}="1",0 ) (would a Switch work here for all 7 responses?)
Print this to table
percent=Count of particular response/total participants*10 0.
Print this to table.

Can anyone help? I am not sure if this should be a UDF or ???.

Thank you in advance, Carolyn
Hi Carolyn,

Your problem exists mainly because you did't "normalize" the table.
You should have created a table with QuestionID, QuestionText, QuestionAnswerT ype.
For the Answers you would need QuestionID, Answerer and Answer.

With these tables you'll be able to do the totalling by using GroupBy queries.

You have two options:
1) Mimic these tables by creating first a UNION query and base the needed GroupBy's on these
2) Use the above UNION queries to fill a redesign of your tables.

The UNION's would look like:
Expand|Select|Wrap|Line Numbers
  1. select ID, "1" as QuestionNo, Q1 from tblQuestions
  2. UNION
  3. select ID, "2" as QuestionNo, Q2 from tblQuestions
  4. UNION
  5. select ID, "3" as QuestionNo, Q3 from tblQuestions
  6. UNION
  7. select ID, "4" as QuestionNo, Q4 from tblQuestions
  8. UNION
  9. ... etc. ...
  10.  
Getting the idea ?

Nic;o)
Oct 27 '07 #2

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

Similar topics

12
2409
by: jason | last post by:
Access 2000: I have a customer-inventory table I need to loop through and compile a list of all the inventory items the customer is tracking. The problem I am finding is that a simple loop will pull out the customer details each time their is an inventory item listed....I need to get the customer out ONCE and list his items....is there an elegant way to do this: Here is the table: Cust-Invent Table
8
2383
by: Peter Bungart | last post by:
I have a text field in Access (XP) that lists the occurrences of various plants, which are delimited within the field by commas (e.g., cactus, mesquite, yucca, cliffrose). Is there a way to tabulate the occurrence of each type of plant within the field, essentially allowing me to consider the text as data which can be analyzed across a geographic area? Would Word or Excel be a better tool for this? I hope my question is clear--its a little...
2
2700
by: JC | last post by:
Hi, I have a database that imports 4 reports to my "data" table, each report has its own identifier. Then I have a table with Analysts with the report identifier that they are to be assigned to. What I need to do is loop the two tables so that an Analyst is assigned to each record in the "data" table based on the identifier. For example, I have one analyst that needs to be assigned to the "H" report records, one analyst that needs to...
16
3541
by: Claudio Grondi | last post by:
Sometimes it is known in advance, that the time spent in a loop will be in order of minutes or even hours, so it makes sense to optimize each element in the loop to make it run faster. One of instructions which can sure be optimized away is the check for the break condition, at least within the time where it is known that the loop will not reach it. Any idea how to write such a loop? e.g.
1
5304
by: iht | last post by:
Fairly new to Access and really doesn't know much about SQL except some basic commands. Currently I'm working with a database that I've already sorted by some queries, and here's a simplified result. Query1: Name A B Smith_A Ya Smith_R Yb Ya Smith_C E Smith_B E Y So far I can count occurrences of "Y" in single fields by using
14
3094
by: David | last post by:
Hi, I have a form on which a user can select a checkbox against a record. Each checkbox carries the RecordID of a product. ---------------------------------------------------------------- I am trying to print the following report:- Details for product 1
4
2215
by: AppDev63 | last post by:
I have a table with a location ID; multiple locations per ID. I need to loop throught that table and create new tables for each location ID so that I can send a report out to each location, containing only the data for that location ID. I also have the email address of the location stored in the same table. How can I loop through this single table, or maybe just filter it programmatically somehow for each location ID and then send an email...
3
2462
by: JDubP | last post by:
I know a bit about VBA in Excel, but not about looping records in Access 2003, so any help will be appreciated. I think if someone can send me some sample code, I can muddle my way through. (or if you can send me alink to read how to do it that is fine also) I presently run a macro that: 1) runs a query where User has to input a value for field and 2) prints/saves a report in snapshot view (i have to manually type in file name) I...
60
5283
by: bonneylake | last post by:
Hey Everyone, What i am trying to do is show previously entered information. I know i need a loop for this , but i am not sure how to loop through this based on my form appears all in the javascript here is my code <cfquery name="serial" datasource="CustomerSupport"> SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,resolution,resolution_date, ...
0
9669
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10427
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9995
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5431
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2916
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.