Change value of a textbox within the BeforeUpdate or AfterUpdate event

rockman

Senior Member
Local time
Today, 15:00
Joined
May 29, 2002
Messages
190
I get an error, "The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing MyDatabase from saving the data in the field.", when I run the following code:
Code:
Private Sub txtHeight_BeforeUpdate(Cancel as Integer)
   If Instr(1,txtHeight.Text,"in") then txtHeight.Text=Val(txtHeight.Text) * 2.54 & " cm"
End Sub
Apparently, Access doesn't like me reassigning txtHeight's value within the BeforeUpdate event. Anyone have an idea on how I can accomplish this task?

Thanks,
Jeff
 
The BeforeUpdate event is a place to do data validation, and cancel the update event if the data fails validation.

It's too late to change the value here because the update is "in process".

Try using the OnLostFocus event instead.

Hope this helps,
 
Thanks Peter that worked.
 

Users who are viewing this thread

Back
Top Bottom