Add one if checked problem

  • Thread starter Thread starter Pattyt
  • Start date Start date
P

Pattyt

Hello,
I have another question. I have the following code in the after_update event
of a check-box and it works fine. The problem is that if I click/unclick and
then click again it keeps adding one to PossiblePoints. PossiblePoints
depends on the selection of a combo box. Ex. If AIM is selected from the
combo box, the initial possible points should be 16, but if they check SelfQA
then it is worth 17 points, however AIM should not be worth anymore than 17.

How can I code this?

Here is the code I have now:

Private Sub SelfQA_AfterUpdate()
If Me![SelfQA] Then 'If the user checks the box
Me!PossiblePoints = Me!PossiblePoints + 1 'Adds one point
End If
End Sub

I appreciate any help. Thanks
 
How are you setting the initial value of PossiblePoints? Are you getting
it from a column in your combo box? If so you could do something like;

Private Sub SelfQA_AfterUpdate()
If Me![SelfQA] Then 'If the user checks the box
If Me!PossiblePoints < (Me!ComboBox.Column(2) + 1) Then
Me!PossiblePoints = Me!PossiblePoints + 1 'Adds one point
End If
End If
End Sub
 
It sounds to me like PossiblePoints is what is known as "derived data" and
it shouldn't be stored at all.

Will it ALWAYS be the same as:
[value derived from combo box] + IIf( [SelfQA], 1, 0 )

If not, then you should make it a calculated field and not store the value.

If it's possible for it to be different then instead of adding 1 to its
*current* value, you should calculate the value by adding 1 or 0 to the base
value, depending on what was selected in the combo box.
 
Sorry for the delayed response,
PossiblePoints is a field in my main table (tblQaActivity) and the value is
obtained by code with a Select Case depending on what item is chosen from the
combo-box. The combo box selection is also stored in the same table.

I need to have both items stored because every month I will have to run
queries and export data to create spreadsheet reports based on possible
points and the selection made from the combo.

I appreciate your help.

Graham Mandeno said:
It sounds to me like PossiblePoints is what is known as "derived data" and
it shouldn't be stored at all.

Will it ALWAYS be the same as:
[value derived from combo box] + IIf( [SelfQA], 1, 0 )

If not, then you should make it a calculated field and not store the value.

If it's possible for it to be different then instead of adding 1 to its
*current* value, you should calculate the value by adding 1 or 0 to the base
value, depending on what was selected in the combo box.
--
Good Luck :-)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Pattyt said:
Hello,
I have another question. I have the following code in the after_update
event
of a check-box and it works fine. The problem is that if I click/unclick
and
then click again it keeps adding one to PossiblePoints. PossiblePoints
depends on the selection of a combo box. Ex. If AIM is selected from the
combo box, the initial possible points should be 16, but if they check
SelfQA
then it is worth 17 points, however AIM should not be worth anymore than
17.

How can I code this?

Here is the code I have now:

Private Sub SelfQA_AfterUpdate()
If Me![SelfQA] Then 'If the user checks the box
Me!PossiblePoints = Me!PossiblePoints + 1 'Adds one point
End If
End Sub

I appreciate any help. Thanks
 
Back
Top