I have got a textbox which is Locked by default, containing the current user's ID. It is necessary to allow some 'special' users to overwrite the userid. Hence I got the dblclick event on the textbox (txtUserID) to un-lock the text box.
As a default a double click will select the contents of the text box. I want to change that behavior and only select part of the text, i.e. the last character. Somehow the code ignors the SelLength and SelStart..... UNLESS I have a breakpoint in the dblclick event (anywhere), in which case it works.
I have inserted DoEvents, Form.Resfresh and sleep 2 secs. None of that made any difference. Google didn't turn up any help either.
This is part of a Access DB (2000 9.0) module (VBA 6.0). What am I doing wrong?
As a default a double click will select the contents of the text box. I want to change that behavior and only select part of the text, i.e. the last character. Somehow the code ignors the SelLength and SelStart..... UNLESS I have a breakpoint in the dblclick event (anywhere), in which case it works.
I have inserted DoEvents, Form.Resfresh and sleep 2 secs. None of that made any difference. Google didn't turn up any help either.
This is part of a Access DB (2000 9.0) module (VBA 6.0). What am I doing wrong?
Code:
Private Sub txtUserID_DblClick(Cancel As Integer)
With txtUserID
.Value = .Text
.locked = Not (.locked)
If .locked Then
.BackColor = 16777215
.TabStop = True
.SetFocus
.SelStart = Len(.Value) - 1
.SelLength = 1
Else
.BackColor = 12632256
.TabStop = False
txtPwd.SetFocus
End If
End With
End Sub