D
DubboPete
Hi all,
It's me and my basketball project again...
I have a form which lists the fixtures for the current round, and I am
trying to update two fields depending on the results.
Imagine we have Team A and Team B playing a fixture. Both teams turn up at
the appointed time, so neither team forfeits the result.
I enter Team A's score of 25, and then Team B's score of 10.
I would like Team A's points to tally 3, and Team B's team to tally 1
Note, in the instance of one team not turning up, therefore forfeiting the
fixture, the [forfeit] option button for that team is clicked, and the team
that did turn up gets 3 points, and the forfeiting team gets 0. In that
event, scores are not required, because obviously there are no scores....
Fields:
[TeamA] is a numeric field
[TeamB] is a numeric field
[Ascore] is numeric
[Bscore] is numeric
[AForfeit] is an option button, for a Yes/No field
[BForfeit] is an option button, for a Yes/No field
[APts] is numeric
[BPts] is numeric
I thought I had cracked it here, but it don't update fields [APts] and
[BPts].
Here's the code
Private Sub B_Pts_AfterUpdate()
If Not IsNull(Me.[AForfeit]) Then
Me.[APts] = 0 'Team A forfeited
Me.[BPts] = 3 'Team B collect the three points
ElseIf Not IsNull(Me.BForfeit) Then
Me.[BPts] = 0 'Team B forfeited
Me.[APts] = 3 'Team A collect the three points
Else
If (CInt(Me.[APts])) > (CInt(Me.[BPts])) Then
Me.[APts] = 3 'Team A won
Me.[BPts] = 1 'Team B lost
ElseIf (CInt(Me.[APts])) < (CInt(Me.[BPts])) Then
Me.[APts] = 1 'Team A lost
Me.[BPts] = 3 'Team B won
Else
Me.[APts] = 1 'drawn game
Me.[BPts] = 1 'drawn game
End If
End If
End Sub
I think that I may be going wrong with the option button part, but I am not
sure...
or maybe I am using "If ... Then ... Else" when it should really be a "Case
Select" code?
Anyone care to guide me back to the true path of the wisdom of VBA coding?
thanks much in anticipation
DubboPete
It's me and my basketball project again...
I have a form which lists the fixtures for the current round, and I am
trying to update two fields depending on the results.
Imagine we have Team A and Team B playing a fixture. Both teams turn up at
the appointed time, so neither team forfeits the result.
I enter Team A's score of 25, and then Team B's score of 10.
I would like Team A's points to tally 3, and Team B's team to tally 1
Note, in the instance of one team not turning up, therefore forfeiting the
fixture, the [forfeit] option button for that team is clicked, and the team
that did turn up gets 3 points, and the forfeiting team gets 0. In that
event, scores are not required, because obviously there are no scores....
Fields:
[TeamA] is a numeric field
[TeamB] is a numeric field
[Ascore] is numeric
[Bscore] is numeric
[AForfeit] is an option button, for a Yes/No field
[BForfeit] is an option button, for a Yes/No field
[APts] is numeric
[BPts] is numeric
I thought I had cracked it here, but it don't update fields [APts] and
[BPts].
Here's the code
Private Sub B_Pts_AfterUpdate()
If Not IsNull(Me.[AForfeit]) Then
Me.[APts] = 0 'Team A forfeited
Me.[BPts] = 3 'Team B collect the three points
ElseIf Not IsNull(Me.BForfeit) Then
Me.[BPts] = 0 'Team B forfeited
Me.[APts] = 3 'Team A collect the three points
Else
If (CInt(Me.[APts])) > (CInt(Me.[BPts])) Then
Me.[APts] = 3 'Team A won
Me.[BPts] = 1 'Team B lost
ElseIf (CInt(Me.[APts])) < (CInt(Me.[BPts])) Then
Me.[APts] = 1 'Team A lost
Me.[BPts] = 3 'Team B won
Else
Me.[APts] = 1 'drawn game
Me.[BPts] = 1 'drawn game
End If
End If
End Sub
I think that I may be going wrong with the option button part, but I am not
sure...
or maybe I am using "If ... Then ... Else" when it should really be a "Case
Select" code?
Anyone care to guide me back to the true path of the wisdom of VBA coding?
thanks much in anticipation
DubboPete