Adding 1 to a field when a value is correct

Nitrous

Registered User.
Local time
Today, 01:15
Joined
Jan 23, 2003
Messages
16
Im having a bit of trouble again!

Im making a testing system for my school, and the answer that they enter is a number, 1 to 5, which is compared to the field where the teacher enters the correct answer.

if a correct answer is entered i want it to compared it to the field and if it is true then I want it to add 1 to the marks field.

The code i have used is: =IIf([Text100]=[tblAnswers.CorrectAnswer],[tblMarks.Mark]+1,[tblMarks.Mark])

This unfortunately does not work, it doesn't change the Mark field at all. Can anyone help?
 
The IIf function evaluates an expression, it won't perform an action. Where are you doing this evaluation? On a form? You can use a bound field in a form (a bound field being a field which has the Mark field as it's controlsource), that way, changes to the field get saved back to the table. Now, in order to set the value of the field, you'll need not an IIF function, but some VBA code. Something like Me.txtMark=Me.txtMark+1.
 

Users who are viewing this thread

Back
Top Bottom