Removing Apostrophe from text fields

wjburke2

Registered User.
Local time
Today, 00:47
Joined
Jul 28, 2008
Messages
194
I have done this before but for some reason when I try now I get a error. Maybe I was using differant code. My code is as follows:

Private Sub txtCamType_BeforeUpdate(Cancel As Integer)
Me.txtCamType = Replace(Me.txtCamType, "'", "")
End Sub

I now get a error BeforeUpdate or VailadationRule property for this field is preventing ... from saving the data in the field
 
Try the after update event.
 
To expand on Paul's correct answer, the reason why you're getting this error is because Access is smart enough to know that if you try to modify the value of control in middle of BeforeUpdate event, it would trigger the BeforeUpdate event again, and thus risking infinite loop. So as a general rule, we don't modify the data inside the BeforeUpdate event but rather use it to validate the data, and use AfterUpdate to do the modifying (e.g. adding formatting, changing the cases or removing unwanted characters as in your case).

I hope that helps some. :)
 
Opps, after update does work better. Don't know why I thought to put it in the before update.
Thanks
 

Users who are viewing this thread

Back
Top Bottom