Users review apps on a daily basis and on a form answer 13 questions with Yes; No; N/A. I need to count across all the Yes; No; and N/A per row (record).
The following sample is how I need the info to display:
App_ID....Q1....Q2....Q3...etc...Total_Y....Total_N.....Total_N/A
1..............Yes...Yes...No.............2...............1..................0
2..............No.....N/A...No............0................2.................1
I wish I can use the countif function as in excel, but this is MS Access 2003. Is there any function, trick, or vba code for solving this problem?
Thx in advance
nrage21
You can do it by changin the table using a recordset:
If you haven't used recordsets before, find some info via Google so you understand how they work, they are handy when you can't use SQL.Set rs = CurrentDb.OpenRecordset("your_Table", dbOpenDynaset) 'Go to the first record. rs.MoveFirst 'Loop through the recordset from first to last. Do Until rs.EOF intYesCount = 0 intNoCount = 0 intNACount = 0 'Check the answer for the first question If rs!Q1 = "Yes" Then intYesCount = intYesCount + 1 If rs!Q1 = "No" Then intNoCount = intNoCount + 1 If rs!Q1 = "N/A" Then intNACount = intNACount + 1 'Check the answer for the second question If rs!Q2 = "Yes" Then intYesCount = intYesCount + 1 If rs!Q2 = "No" Then intNoCount = intNoCount + 1 If rs!Q2 = "N/A" Then intNACount = intNACount + 1 'Check the answer for each answer in the same pattern. '... '... '... 'Put the found values into your total fields. rs!Total_Y = intYesCount rs!Total_N = intNoCount rs!Total_NA = intNACount rs.Update rs.MoveNext
If you set up your table differently, you could find your results using SQL.
If you changed your table to three fields:
App_ID; Question_ID; Answer
You could then use the count function in SQL, and specify the app with the WHERE clause to find totals by app. You could also use the count function and specify the Question_ID in the where clause to find the totals by question.
Is your code running too slowly?
Does your workbook or database have a bunch of duplicate pieces of data?
Have a look at this article to learn the best ways to set up your projects.
It will save both time and effort in the long run!
Dave
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks