cursor missing in textbox

Deekay

New member
Local time
Today, 23:07
Joined
Apr 7, 2013
Messages
4
no cursor in text box!
I thought I was pretty savvy on VBA but....

I have a routine to filter a recordset that is triggered by the onChange from a textbox called 'textSearch' control event. The idea is meant to be that as the user keeps typing the recordset becomes progressively more filtered. So far so good. The recordset changes works fine. Afterwards each OnChange event I am using setfocus to move the focus back to the form (it seems to need this) and then once more on the 'textSearch' control. (I have tested by seeting a backcolor change that this control really does have the focus at this point). BUT....

!!No blinking cursor!! so the user cannot type more than one character at a time into the textbox. (The cursor only appears if you use the mouse to click inside the control - but that defeats the purpose of the coding). I have tried SetFocus, GotoControl and SelStart all with no avail. Can anyone help and tell me why the cursor is not there (and how to get it back)? Thanks. Here's the code.....

Code:
Private Sub textSearch_Change()

Dim searchText As String
Dim temp As Integer

'On Error GoTo err_textSearch_Change

searchText = Me.textSearch.Text
temp = Me.textSearch.SelStart

'***now calls the executeSearch procedure***

executeSearch (searchText)

Forms![Members Details].SetFocus
Me.textSearch.SetFocus
Me.textSearch.SelStart = temp
Me.textSearch.BackColor = 10802658             ' just for testing

exit_textSearch_Change:
    
Exit Sub
    
err_textSearch_Change:

    MsgBox Err.Descripture
    Resume exit_textSearch_Change

End Sub
 
Perhaps I have misunderstood what it is you are doing. However it sounds as if it is similar to what the sample here is doing. Perhaps it will give you some pointers.
 
As an alternative to JBB's suggestion, I use a routine as follows:

QuickFind is the equivalent of your TextSearch.

Code:
Private Sub QuickFind_Change()
    SFData.Form.Filter = "[Field1] & '|' & [Field2] & '|' & [Field3] & '|' & Like '*" & QuickFind.Text & "*'"
    SFData.Form.FilterOn = True
End Sub

Substitute Fields1...x for your subform source fieldnames and I use a pipe to separate fields to avoid bleed from one field to the next.

SFData is the name of your subform control

This works and does not involve the QuickFind control losing focus
 
no cursor in text box!
I thought I was pretty savvy on VBA but....

I have a routine to filter a recordset that is triggered by the onChange from a textbox called 'textSearch' control event. The idea is meant to be that as the user keeps typing the recordset becomes progressively more filtered. So far so good. The recordset changes works fine. Afterwards each OnChange event I am using setfocus to move the focus back to the form (it seems to need this) and then once more on the 'textSearch' control. (I have tested by seeting a backcolor change that this control really does have the focus at this point). BUT....

!!No blinking cursor!! so the user cannot type more than one character at a time into the textbox. (The cursor only appears if you use the mouse to click inside the control - but that defeats the purpose of the coding). I have tried SetFocus, GotoControl and SelStart all with no avail. Can anyone help and tell me why the cursor is not there (and how to get it back)? Thanks. Here's the code.....

Code:
Private Sub textSearch_Change()
 
Dim searchText As String
Dim temp As Integer
 
'On Error GoTo err_textSearch_Change
 
searchText = Me.textSearch.Text
temp = Me.textSearch.SelStart
 
'***now calls the executeSearch procedure***
 
executeSearch (searchText)
 
Forms![Members Details].SetFocus
Me.textSearch.SetFocus
Me.textSearch.SelStart = temp
Me.textSearch.BackColor = 10802658             ' just for testing
 
exit_textSearch_Change:
 
Exit Sub
 
err_textSearch_Change:
 
    MsgBox Err.Descripture
    Resume exit_textSearch_Change
 
End Sub

Have you checked this ?

Best,
Jiri
 
Dear Brent and John

Thank you for your replies.

Brent - I had already tried your suggestions but the problem I have is that the cursor does not appear after I set the focus back to the Form. No keyboard strokes at all have any effect - not even tab to move between fields. The only thing that works is to first use the mouse to click back inside the form - only then does the cursor reappear.

John - I had a look at this routine as part of my research and considered using this. I found another example which basically creates an SQL on the same method which is used to change the recordset. There is something about changing the recordset that appears to be stopping the form from receiving keyboard inputs. Stangely, if you interrrupt my code with a Msgbox at the point where I had a background colour change, the cursor returns after the Msgbox is closed.

I will try using the query instead as the search routine and find out what happens. (Although I won't be able to do this until tomorrow. I will post again and say whether it works.)

David
 
I am facing the same problem, did you find the solution?
 

Users who are viewing this thread

Back
Top Bottom