Update textbox during typing

Viewed 16259

In Access, I have a form in which there are three textboxes. I am trying to update a textbox called tbxCombinedName with a combination of both:

  • textbox tbxLastName (person's Last Name)
  • textbox tbxFirstName (person's First Name)

My question is: what textbox property do I use, so that as I am typing text in tbxLastName, the CombinedName textbox is updated immediately and thereafter saved in the table Contacts.

On Microsoft's website, I have found that the step processes when typing in a textbox are as follows:

KeyDown → KeyPress → BeforeInsert → Change → KeyUp

I've tried using the OnChange and OnKeyDown properties, but to no avail. Which property, combined with what code, will allow the update-as-you-type action to work?

This is what I wrote earlier, which didn't work:

Private Sub tbxLName_change()

Dim lastName As String
Dim nameCode As String

lastName = tbxLName.Value
Debug.Print lastName
nameCode = tbxNameCode.Value
nameCode = lastName
Debug.Print nameCode

End Sub

Thanks for all your help in advance.

2 Answers
Related