G
Guest
Hi all,
I am trying to write some code to make sure that data in a certain text box
is compliant with certain rules. This is the code:
-------------------------- code starts here --------------------------
Private Sub sparNum_BeforeUpdate(Cancel As Integer)
If Me!sparNum < 1 Then
MsgBox "Il campo 'Numero' può contenere solo valori numerici
positivi.", vbExclamation, "Valore non valido"
Cancel = True
End If
End Sub
-------------------------- code ends here ---------------------------
the sparNum textbox is a required field, numeric, integer, and no other
validation rules exist.
the problem is:
after the MsgBox fires, the flow goes to the form_error routine, 'cause an
error 2116 has been generated. I cannot get rid of it, and I am also not able
to clear the textbox, after the errors the negative number is still there (so
what is the Cancel for if setting it to True does not delete the value), even
me!sparNum.undo does not clear it (me!undo actually does, but clears also all
the other fileds ...) and if aI try to put some code to delete it, there are
several errors...
What am I doing wrong?
And do you know where I can find a detailed list of the possible error
numbers with some explainations?
any help very much appreciated.
thanks
Massimo
I am trying to write some code to make sure that data in a certain text box
is compliant with certain rules. This is the code:
-------------------------- code starts here --------------------------
Private Sub sparNum_BeforeUpdate(Cancel As Integer)
If Me!sparNum < 1 Then
MsgBox "Il campo 'Numero' può contenere solo valori numerici
positivi.", vbExclamation, "Valore non valido"
Cancel = True
End If
End Sub
-------------------------- code ends here ---------------------------
the sparNum textbox is a required field, numeric, integer, and no other
validation rules exist.
the problem is:
after the MsgBox fires, the flow goes to the form_error routine, 'cause an
error 2116 has been generated. I cannot get rid of it, and I am also not able
to clear the textbox, after the errors the negative number is still there (so
what is the Cancel for if setting it to True does not delete the value), even
me!sparNum.undo does not clear it (me!undo actually does, but clears also all
the other fileds ...) and if aI try to put some code to delete it, there are
several errors...
What am I doing wrong?
And do you know where I can find a detailed list of the possible error
numbers with some explainations?
any help very much appreciated.
thanks
Massimo