J
jfp
I have an unbound control named "edtCopies" on a form. This is the code
for BeforeUpdate :
Private Sub edtCopies_BeforeUpdate(Cancel As Integer)
If ((edtCopies < 1) Or (edtCopies > 100)) Then
MsgBox "# of copies must be between 1 and 100.", vbExclamation
edtCopies.Undo
Cancel = True
End If
End Sub
The value of the control is initialized to "1".
If i change that to "123" and try to leave the field (Tab, Enter, etc.)
then:
The message box pops up,
I acknowledge it,
The value "123" remains in the control, but is now highlighted
If i then move to some other control, the (illegal) value 123 remains in
the control.
If i set a breakpoint on the first line in the Sub,
BOTH edtCopies.Value and edtCopies.OldValue are seen to be "123".
Thus, perhaps, Undo is "working" in that it is restoring the old value
-- but why is the old value wrong?
What is happening here ?
I have used this same type of logic on other projects (running on the
same PC - same Access 2002 etc.) without a problem. Is there some
setting or option that could have gotten messed up in this project (or
form) ?
for BeforeUpdate :
Private Sub edtCopies_BeforeUpdate(Cancel As Integer)
If ((edtCopies < 1) Or (edtCopies > 100)) Then
MsgBox "# of copies must be between 1 and 100.", vbExclamation
edtCopies.Undo
Cancel = True
End If
End Sub
The value of the control is initialized to "1".
If i change that to "123" and try to leave the field (Tab, Enter, etc.)
then:
The message box pops up,
I acknowledge it,
The value "123" remains in the control, but is now highlighted
If i then move to some other control, the (illegal) value 123 remains in
the control.
If i set a breakpoint on the first line in the Sub,
BOTH edtCopies.Value and edtCopies.OldValue are seen to be "123".
Thus, perhaps, Undo is "working" in that it is restoring the old value
-- but why is the old value wrong?
What is happening here ?
I have used this same type of logic on other projects (running on the
same PC - same Access 2002 etc.) without a problem. Is there some
setting or option that could have gotten messed up in this project (or
form) ?