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:
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.
This is one of the few cases where you should refer to the .text property.
In the Change event:
lastName = tbxLName.Text
The .text property is only available when a control has focus and it refers to the visible contents of the control.
However, this is a database and the general rule is that you no not store calculated fields. The full name can easily be obtained from a query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With