Changing value in beforeupdate

J

John J.

In a field's beforeupdate I validate a value. When the value is not valid,
I'd like to change this field's value to null. However, when I try to do
that, I get an error, saying that the value can not be stored:

Private Sub test_BeforeUpdate(Cancel As Integer)
If test = 1 Then
msgbox "Wrong value"
Cancel = True
test = null
End If
End Sub

Any ideas on how to make this work?

Thank you.
John
 
A

Allen Browne

You may be able to Undo the control, but it's generally not a good idea to
alter the value in its BeforeUpdate.

Additionally, you won't be able to assing Null (in any event) if it is bound
to a required field.
 
J

John J.

Thanks.
Back to the drawing board...

Allen Browne said:
You may be able to Undo the control, but it's generally not a good idea to
alter the value in its BeforeUpdate.

Additionally, you won't be able to assing Null (in any event) if it is
bound to a required field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top