CaTz
CaTz

Reputation: 315

How replace text value of textbox in access 2007

I have text-box in some form in access 2007. I am trying to replace all the dots(.) in the text of the text box with some VBA.

This is what i did:

Private Sub eng_name_LostFocus()
    Dim val As String
    val = Replace(eng_name.Value, ".", " ")
    eng_name.Value = val
End Sub

but its do nothing...

what can i change to work it out?

Upvotes: 0

Views: 2399

Answers (1)

Jacob
Jacob

Reputation: 43229

Private Sub eng_name_AfterUpdate()
    Me!eng_name = Replace(Me!eng_name, ".", " ")
End Sub

I think you only need AfterUpdate, as it is only triggered when the value of eng_name is changed.

I always use Me!ControlName to get/set the value of a control in Access.

Upvotes: 1

Related Questions