I'm having trouble getting to the text that is currently displayed in a bound text box. I'm trying to provide a keyboard shortcut for users to insert @ signs into email addresses on PCs that do not have full keyboards. I'm using onKeyPress to trap a control + key combination (I've selected Ctl+E as all the obvious ones have gone). The control in question is called txtEmail and is bound to a text field. In the KeyPress event I use
strEmail = Me.txtEmail
strEmail = strEmail & "@"
Me.txtEmail = strEmail
Me.txtEmail.SelStart = Len(Me.txtEmail)
This adds the @ sign, deselects the text then places the insertion point at the end of the new string ready for the rest of the email. However, if there is already an entry in this field, which has to be changed, when the user deletes the previous entry, enters the new address and presses Clt+E, the old entry reappears and the new entry is lost.
Obviously for fields that already contain data Me.txtEmail is looking at the saved entry in the table. Is there a way of referencing the current contents of the textbox rather than the contents of the bound field?