Objective : The user requires to enter data into a text field without having to highlight it before typing over what was there before. This works if the user uses the up/down key to go to the next record, but when they use the mouse to go to a specific row I'm trying to find a way of highlighting that field (ie in reverse video). I've tried using the code: SendKeys "+^{RIGHT}" in the 'OnFocus' event but to no avail.
Data Entry
Collapse
X
-
Hey Mallard!
You can use this code in the control's OnClick event:
This way when you click on that control (txtSearchStrin g in my example)Code:Private Sub txtSearchString_Click() Me.txtSearchString.SelStart = 0 Me.txtSearchString.SelLength = Len(Nz(Me.txtSearchString, 0))
the content of the control is selected and you can type over it.
Note that Nz(ControlName, 0) is used in order to avoid err when control is empty (null).
Hope it helps, H. -
That should work - except possibly change the third line so that Nz() uses "" if value Null instead of 0.
Or why not use the With construct to make the code more efficient and easier to read :Code:Private Sub txtSearchString_Click() Me.txtSearchString.SelStart = 0 Me.txtSearchString.SelLength = Len(Nz(Me.txtSearchString, "")) ...
Code:Private Sub txtSearchString_Click() With Me.txtSearchString .SelStart = 0 .SelLength = Len(Nz(.Value, "")) End With ...
Comment
Comment