randika100100
Registered User.
- Local time
- Tomorrow, 03:17
- Joined
- Aug 31, 2011
- Messages
- 11
I have a subform in datasheet view and a text box to put values to search and the results are displayed in the datasheet.I have code in Text_Change Event so whenever user press a button inside the text box, it will setup the sql and requery the datasheet to provide a live search. But in the process of setting up the query, it will lose focus from the text box and as a solution I put
to set the cursor back on the correct position inside the textbox so user can keep typing. I want to be able to detect if user has pressed space then I have to set it like
But unfortunately it doesn't work. I can't understand why. textbox.SelStart and textbox.SelLength only seems to work outside the KeyDown_Event. It works perfectly when I put it in the Text_Change event and it sets the cursor in the correct position. But then I can’t see a way to get the keycode when im in Text_Change Event to allow user to put space between text.Can some one please help me. Thanks in advance
Me.filterValue.SetFocus
Me.filterValue.SelStart = Me.filterValue.SelLength
to set the cursor back on the correct position inside the textbox so user can keep typing. I want to be able to detect if user has pressed space then I have to set it like
So I tried thisMe.filterValue.SetFocus
Me.filterValue.SelStart = Me.filterValue.SelLength + 1
Private Sub filterValue_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode=32 Then
Me.filterValue.SetFocus
Me.filterValue.SelStart = Me.filterValue.SelLength + 1
Else
Me.filterValue.SetFocus
Me.filterValue.SelStart = Me.filterValue.SelLength
End Sub
But unfortunately it doesn't work. I can't understand why. textbox.SelStart and textbox.SelLength only seems to work outside the KeyDown_Event. It works perfectly when I put it in the Text_Change event and it sets the cursor in the correct position. But then I can’t see a way to get the keycode when im in Text_Change Event to allow user to put space between text.Can some one please help me. Thanks in advance