Cursor to the left end without selection?

B

Barcode

Hello

I have a form with a field called "search" when I write on it, so I wiould
like to find code that make on change after refresh the cursor will be to the
left to continue writing.
Now when I write, with every key pressing it will be refresh and the
selection is being on the character I wrote, so I cannot write more than only
one character.

I need a code that put the cursor to the left hand side so that I can
continue writing inside that field.
The field that I wrote inside it, contains the following code:

Private Sub Search_Change()
Me.Refresh

End Sub

Any help ?
 
B

Barcode

Thank you for help

I test it and it is work when I have to move to next field, but I have only
one field and that's why the mark be on all the text that is inside thr field
after command Me.refresh.
Is there code that can write it on field "on change"

Thanks a lot
 
A

Arvin Meyer [MVP]

Yes, you can, You can use the Enter event as well:


Private Sub Test_Enter()
Me.Test.SelStart = 0
End Sub

But you'll have the same problem if you use a mouse, it will always leave
you where you click. That's a Windows and MouseDriver issue.
 
B

Barcode

Hello

Thank you for your help. It work good now and I can use the search function
without problem.

But I would like to ask you; why my old code was working good on MS Access
2000 - 2003 but not work on Access 2007 ?

Here is the code, do you have any recommend about it, though it work now,
when I put the "refresh and selstart"?

Best wishis


Private Sub Search_Change()
' All those query is to same Table, but diffrent is colum name
' that is linked to field "Search" on this Form.

If Me.Option = 1 Then
Me.serv.Form.RecordSource = "SearchSv"
ElseIf Me.Option = 2 Then
Me.serv.Form.RecordSource = "SearchArb" ' to search on arabic word
ElseIf Me.Option = 3 Then
Me.serv.Form.RecordSource = "SearchSv2" ' to search on arabic word
ElseIf Me.Option = 4 Then
Me.serv.Form.RecordSource = "SearchArb2"
End If

' IF, it make cursore on left side to
' write arabic
' ELSE THEN cursore will be on right
' side to write english on search field
If Me.Option = 1 Or Me.Option = 3 Then
Me.Requery
DoCmd.Requery "serv"
Dim dbs As Database, rs As Recordset
Set dbs = CurrentDb
Set rs = Me.serv.Form.Recordset
SendKeys "{F2 2}"
End If

' This function need only for Access 2007
Me.Refresh
Me.Search.SelStart = 0

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top