I have an Access 2003 database. On one of the forms, I have a textbox, called txtTotal, whose control source is set to add up all of the rest of the textboxes on the form (there are several).
I have to ensure txtTotal never exceeds 100 (this is actually formatted as Percent, so I'm checking to see that 100% is not gone over)
I figured it would be pretty easy by doing
Code:
Private Sub txtTotal_Change()
If Val(txtTotal.Text) > 100 Then
MsgBox "The total for the this metric can not exceed 100%.
Please make the necessary adjustments."
, vbOKOnly + vbExclamation, "Total Exceeds 100"
txtTotal.ForeColor = vbRed
txtTotal.FontBold = True
Else
txtTotal.ForeColor = vbBlack
txtTotal.FontBold = False
End If
End Sub
But, much to my surpise the code never ran because the event did not fire when the total in the textbox changed. So, I moved the above code to the AfterUpdate event....that never fired either nor did the BeforeUpdate event.
In each of these events I had a break set on the Private Sub line. But nothing happened on any occasion.
I am pretty experienced in VB6 and VB.NET...not so much in VBA so I don't know what I'm missing here. Why aren't these events firing when I make a change to the totals textbox?