Getting a 'score' for a question

R

RebeccaMinAR

I thought I had this working, and now it's not - so some help would be
appreciated.

I have a series of questions, sort of like one of those Cosmo quizzes where
each answer has a different point value. I have the questions and answers in
a three column table (Question_type Question_Response and Question_Value). I
have a series of combo boxes where the responses for each question are
chosen. This part works fine.

However, I need to have a box for the score, and then a way to add the
responses. I can use a list box to select the correct score, but when I do so
it's not 'selected' it's just the only value to display. How do I display the
scores correctly? Text box doesn't have an obvious way to do it (although it
seems to be the right approach somehow). Any assistance would be greatly
appreciated - I've been beating myself over the head for days with this one.
 
B

Barry Gilbert

In the rowsource of you combobox, add the score column and set it's width to
0 using the column widths property. In the AfterUpdate of each combobox,
point to a new routine that sums the chosen scores from each combo and put
them into a textbox. Something like this:

Private Sub cboQuest1_AfterUpdate()
SumScores
End Sub

Private Sub SumScores()
With Me
.txtScore = .cboQuest1.Column(1) + .cboQuest2.Column(1) +
..cboQuest3.Column(1)
End With
End Sub

If you have too many comboboxes to make this practical, you could do a loop
through the form's comboboxes to get their values.

Barry
 
R

RebeccaMinAR

Barry,

I've got all my combo boxes set up with the two columns. (the score column
is second). I have set the default value for my 'totals' text box to 0 so I
can see when it's making a change, and it's now blank so something is trying
to happen. However, when I set up the private sub (and since it's dividing
itself off from the Private Sub for the After Update event, I'm assuming I
only need to do it once for the entire form), it doesn't return an erro but
also doesn't do anything.

This is what I have

Private Sub ED_Project_Type_AfterUpdate()
Sumscores
End Sub
------------------------------------------------------------------------------
Private Sub Sumscores()
With Me
.Text31 = .ED_Project_Type.Column(2) + .ED_Project_Effort.Column(2) +
..ED_Project_Risks.Column(2) + .ED_Technology_Innovation.Column(2) +
..ED_Schedule.Column(2) + .ED_Team_Skill_Level.Column(2) +
..ED_External_Client_Involvment.Column(2) + .ED_Vendor_Involvement.Column(2)
End With
End Sub

What am I doing wrong? Your help is greatly appreciated!
 
B

Barry Gilbert

Remember that the Columns collection is zero-based. This means that you refer
to the first column as .Column(0) and the second column as .Column(1). This
is probably the cause of your problem.

You also need to call this routine from the AfterUpdate of every one of you
comboboxes.

Barry
 
R

RebeccaMinAR

Barry - I'm () that close to having this resolved. I've changed the (2) to
(1) on all of my references, and it's already called in the AfterUpdate on
all the combo boxes, so as soon as I went in and changed on it magically
worked - except that it's showing 32243222 instead of the sum of those
numbers. If I change the second one, it changed to 34243222 so it's updating
properly, just not adding the numbers (it seems to be thinking it should
concatenate instead). If I enclose all of the information after the = sign in
parentheses and put Sum in front, it doesn't like the sum and pops up the
debugger. Hints? I really appreciate your help - this has been six weeks of
work for me, getting this dratted database done, and I'm at the finish line.

--Rebecca
 
D

David Cox

the + sign means concatenate if between two string values.

A fudge is to use val([field1) + val([field2]), but getting the fields to be
numeric is the better way to go.
 
B

Barry Gilbert

Try this:
With Me
.Text31 = CInt(.ED_Project_Type.Column(1)) +
CInt(.ED_Project_Effort.Column(1)) + CInt(.ED_Project_Risks.Column(1)) +
CInt(.ED_Technology_Innovation.Column(1) + CInt(.ED_Schedule.Column(1)) +
CInt(.ED_Team_Skill_Level.Column(1) +
CInt(.ED_External_Client_Involvment.Column(1) +
CInt(.ED_Vendor_Involvement.Column(1))

The CInt() function converts all the values to an integer.

Barry
 
R

RebeccaMinAR

Barry, you're a genius. I had to go tinker with the source table and make
sure that the scores were specified as 'single' and not 'long integer' (the
default) but once I did that, I got the correct response - a sum! Thank you
so much - this makes my whole month!

--Rebecca
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top