Updating a control for a points scoring system

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to create a scoring system for every time a user gets a correct answer
and place the value in a form control.

I have an Answer combo Box that if the user selects the correct answer,
updates an unbound ‘Answer’ text box with the value “Yes†or “Noâ€.

What I would like to do is have the value from the ‘Answer†text box update
an unbound ‘Scorebox’ control on the form each time the user gets a Yes
answer. (It doesn’t matter if they get a No). I would like to increment the
value by 1 each time.

I don’t need to save the results, though that could be very useful for
latter development.

I have tried to update the ‘Scorebox’ control with a ‘SetValue’ macro, but
that doesn’t do anything. I’m baffled as to why.

Hear is the format of my Macro

Condition:
[Forms]![TestForm]![frm_PointsTest_A].[Form]![answer_box]="Yes"

Action:
SetValue

Item:
[Scorebox]

Expression:
+1

Am I missing something obvious here, or is my database unwell?

What is the best way to go about this?
 
Efandango,

First of all, the Expression argument in the macro should be:
[Scorebox]+1

However, you don't say what event you are using to run the macro. Nor
how you go about the process to "updates an unbound ‘Answer’ text box
with the value “Yes” or “No”. " But when the "Yes" is added to the
answer_box, this does not trigger any event on that control really. Why
don't you update the value of the Scorebox control at the same time and
in the same way that you update the value of the answer_box control.
 
Steve, thanks for your help.

The macro event is on the drop down 'answer combo'. It first checks if the
selection matches the underlying table field (Run_point_Address_A) via a
macro, if it does, it then updates the 'Answer' text box to correctly display
'Yes'.

The macro for that part is:

Action: SetValue
Item: [Answer_box]
Expression: IIf([Combo_Answer]=[Run_point_Address_A],"Yes","No")


Your suggestion that i change the update expression in the macro to
[Scorebox]+1 did the trick of adding an increment. But why does that work,
when I had already stated the 'Item' in the Item box on the macro?. Or should
i Have just left that entry blank?

also, I get the strangest error message when I leave the 'Answer Combo' for
the next record (question).

The error message is exactly as follows: (note the punctuation symbols,>'.)

Microsoft Office Access can't find the Macro '


*****************************************************
'
..

The Macro (or its macro group) doesn't exist, or the macro is new but hasn't
been saved.
Note that when you enter the macrogroupname.macroname syntax in an argument,
you must specify the name the macro's group was last saved under.

*****************************************************


I only get this error when the correct answer is chosen, if it is a No
answer, it happily lets me move to the next record for a new question.


Steve Schapel said:
Efandango,

First of all, the Expression argument in the macro should be:
[Scorebox]+1

However, you don't say what event you are using to run the macro. Nor
how you go about the process to "updates an unbound ‘Answer’ text box
with the value “Yes†or “Noâ€. " But when the "Yes" is added to the
answer_box, this does not trigger any event on that control really. Why
don't you update the value of the Scorebox control at the same time and
in the same way that you update the value of the answer_box control.

--
Steve Schapel, Microsoft Access MVP
I want to create a scoring system for every time a user gets a correct answer
and place the value in a form control.

I have an Answer combo Box that if the user selects the correct answer,
updates an unbound ‘Answer’ text box with the value “Yes†or “Noâ€.

What I would like to do is have the value from the ‘Answer†text box update
an unbound ‘Scorebox’ control on the form each time the user gets a Yes
answer. (It doesn’t matter if they get a No). I would like to increment the
value by 1 each time.

I don’t need to save the results, though that could be very useful for
latter development.

I have tried to update the ‘Scorebox’ control with a ‘SetValue’ macro, but
that doesn’t do anything. I’m baffled as to why.

Hear is the format of my Macro

Condition:
[Forms]![TestForm]![frm_PointsTest_A].[Form]![answer_box]="Yes"

Action:
SetValue

Item:
[Scorebox]

Expression:
+1

Am I missing something obvious here, or is my database unwell?

What is the best way to go about this?
 
Efandango,
Action: SetValue
Item: [Answer_box]
Expression: IIf([Combo_Answer]=[Run_point_Address_A],"Yes","No")

I must admit I am amazed that this works. That's not how I would have
done it. But if it gives the correct result, that's cool.

I would have used Conditions in the macro, like this:

Condition: [Combo_Answer]=[Run_point_Address_A]
Action: SetValue
Item: [Answer_box]
Expression: "Yes"
Condition: [Combo_Answer]<>[Run_point_Address_A]
Action: SetValue
Item: [Answer_box]
Expression: "No"
Your suggestion that i change the update expression in the macro to
[Scorebox]+1 did the trick of adding an increment. But why does that work,
when I had already stated the 'Item' in the Item box on the macro?. Or should
i Have just left that entry blank?

You don't want to set the value of the Scorebox to "+1". You want to
set the value of the Scorebox to (the existing value of the Scorebox)+1.
also, I get the strangest error message when I leave the 'Answer Combo' for
the next record (question).

I don't know what event you are using to run the macro you have
explained above, nor do I know what other macros might be assigned on
other events related to this form. So I can't comment specifically. It
sounds like you have something incorrect with the way you have assigned
a macro.
 
Steve,

I'm puzzled and curious about your 'amazed' comment. Why would you have not
done it the way that I have, is their some inherent problem that may cause
problems elsewhere or is it just not 'the convention'. I am keen to hear your
comments as I am not really experienced enough to know the differences.

Also, can you help with this further problem?


Despite what I said earlier, I now I need to store the values somewhere, but
if I bind the calculated control to a table field it doesn’t work. So where
and HOW would I store the data if it won’t go in a table?


Can you give me some general pointers as to what the overall structure or
direction should be to make this work


The underlying table simply consists of just four fields which serve the
existing requirement to display a question and its answer counterpart field,
they are.

Run_No: (Autonumber)
Point_Quiz_ID (Number generated by an append underlying query)
Run_point_Venue_A (This is the question)
Run_point_Address_A (This is the answer)

This table is linked to the form with the Unbound text boxes previously
mentioned. One is the drop-down Combo box, which displays the 10 suggested
answers to the question. Once the user has selected the correct answer, an
AfterUpdate macro does a SetValue on a Text Field Box setting its value to
either Yes or No.

My problem is that I want to be able to now store the score for number of
questions guessed correctly, but cannot find a way of storing an unbound or
calculated control.


Steve Schapel said:
Efandango,
Action: SetValue
Item: [Answer_box]
Expression: IIf([Combo_Answer]=[Run_point_Address_A],"Yes","No")

I must admit I am amazed that this works. That's not how I would have
done it. But if it gives the correct result, that's cool.

I would have used Conditions in the macro, like this:

Condition: [Combo_Answer]=[Run_point_Address_A]
Action: SetValue
Item: [Answer_box]
Expression: "Yes"
Condition: [Combo_Answer]<>[Run_point_Address_A]
Action: SetValue
Item: [Answer_box]
Expression: "No"
Your suggestion that i change the update expression in the macro to
[Scorebox]+1 did the trick of adding an increment. But why does that work,
when I had already stated the 'Item' in the Item box on the macro?. Or should
i Have just left that entry blank?

You don't want to set the value of the Scorebox to "+1". You want to
set the value of the Scorebox to (the existing value of the Scorebox)+1.
also, I get the strangest error message when I leave the 'Answer Combo' for
the next record (question).

I don't know what event you are using to run the macro you have
explained above, nor do I know what other macros might be assigned on
other events related to this form. So I can't comment specifically. It
sounds like you have something incorrect with the way you have assigned
a macro.
 
Efandango,

Sorry, I was not really commeting on what you had done specifically.
It's just that it would have never occurred to me that the result of an
IIf() function would be accepted by the Expression argument of a
SetValue action. Don't know why, just not what I would expect. Ah, well.

The score (number of correct answers or whatever) should normally not be
stored in a table. Normally, it would be calculated in a query, based
directly on the answers, whenever required for your operational (form or
report) purposes.
 
Steve,

Can you help with this rather desperate situation that is causing havoc!

It is also the reason that I can't bind the score to it's field in the
underlying table, and have been in a way misinforming you that i can't bind
the score, without actually explaining clear enough that it is the error that
gets in the way, becuase I am tussling with the error and trying to fix it,
by binding/unbinding. Even though, after I clear the error, the correct data
score is in the record within the table.

Here's the message, verbatim (asterix's to just show the message box).

*****************************************************
Microsoft Office Access can't find the Macro ''
..

The Macro (or its macro group) doesn't exist, or the macro is new but hasn't
been saved.
Note that when you enter the macrogroupname.macroname syntax in an argument,
you must specify the name the macro's group was last saved under.

***************************************

Now when the score box(s) are unbound, I don't get the error, but whenever i
bind them to the appropriate control, I get the above error message.
 
Steve,

Ignore the last post where i Need help with a Macro Error Message. I have
resolved the issue. The problem was a corrupt form. I created a new form,
rebuilt the various controls, and it worked.

however, I need some advice on the best way to limit the Scorebox control to
just the digit 1.

At the moment, the control box in the SetValue macro says: [Scorebox]+1.
This works fine; but if the user hits the same answer again while staying on
the same record, the scorebox macro invokes another [Scorebox]+1, making the
Scorebox now read 2, which is incorrect.
 
Efandango,

Maybe I have misinterpreted. I thought the Scorebox was a textbox where
the cumulative score is displayed. In other words, it increases by 1
for each correct response. So therefore it will show the total number
of correct responses. It now appears that there may be one scorebox for
each record, and shows 1 for correct for only that response?

It sounds like, from a user interface point of view, that you need to
devise a way to prevent the user from answering the same question more
than once. Is that right?

Is the Answer combobox on a continuous view form? With one for each
"question"? (I suppose you have questions... actually you haven't said
what this is all about yet!)
 
Back
Top