Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cursor Position in Text Box

Status
Not open for further replies.

DougAtAvalon

Programmer
Jan 29, 2001
99
US
Does any one know how to put the cursor ata particular position in a text box. What's happening is the entire text in the box is being highlighted so the next thing the user types erases what he/she has typed. I would like the user to be able to keep typing.

-Doug
 
Private Sub Form_Open(Cancel As Integer)
Me.Text0 = "naodf asdf asdf ad safd "
SendKeys "{F2}"
End Sub

s-)
ide
 
You know I'm still having a problem. thias is what happens

On the Change event of the text box it executes code that searches for a match in the list box.

If it doesn't find a match I can keep typing.
If it finds a match, the text gets highlighted.

*******************************8
Private Sub SearchFor_Change()
'From Microsoft
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String

Set db = CurrentDb
If Me.FindBy = "Congregation" Then strSQL = "SELECT OrgID, Congregation " & _
"FROM Organizations WHERE Congregation LIKE '" & _
Me!SearchFor.Text & "*'"

If Me.FindBy = "City" Then strSQL = "SELECT OrgID, City " & _
"FROM Organizations WHERE City LIKE '" & _
Me!SearchFor.Text & "*'"

If Me.FindBy = "State" Then strSQL = "SELECT OrgID, State " & _
"FROM Organizations WHERE State LIKE '" & _
Me!SearchFor.Text & "*'"

Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)

If rs.RecordCount > 0 Then
rs.MoveFirst
Me!CongregationList = rs!OrgID
CongregationList_AfterUpdate
SendKeys "{F2}"
End If

rs.Close
Set rs = Nothing
Set db = Nothing

End Sub
 
I'm sorry Doug, but i don't understand: what's your problem?

:)
 
The Code structure is this:

1. On the TextBox change event find a value in list box and highlight it

2. Then execute the code that would normally happen if you clicked on the list box (After update enent of list box)

3. For example:

LIST TEXT BOX: T
Access
Thousand
TekTips
TekTipes


...........here if i want to find "TekTips" the "Thousand" gets highlighted when I type "T". That's OK and understandable, but it highlights the "T" preventing me from typing more. . . it seems as soon as it finds a match it "highlights". That Send Keys doesn't do it.

thanx,
Doug
 
Doug,
...
me.SearchFor.setfocus
SendKeys "{F2}"
...

Is it right?
Hope this helps you

ide s-)
 
No it doesn't help cause I have:

CongregationList_AfterUpdate
SendKeys "{F2}"

And if there's a like match it highlights

....But I like your smiley face that turns around how'd you do that?

-Doug
 
CongregationList_AfterUpdate
me.SearchFor.setfocus
SendKeys "{F2}"

it's wrong ?

ide
smiley: s-)
 
Yes it works correctly until it finds a match
When it finds a match it (Ex. type "Tekt"
-executes the auto update and finds "TekTips"
-Then it highlights ("Tekt")

therefore I can't keep typing to find "TekTipes" because it already found another match and highlighted the text box

If you don't know what to do that's Ok, I'll just make the user hit enter to execute the "CongregationList_AfterUpdate" code.

-Doug
 
Dear Doug:
One thing has me confused: When I'm typing in a box to search for a record (it may be in a combo box), and the text is highlighted because it has found a record matching the intial characters that have been entered, nothing prevents me from typing on...and on...
I can type "sm" looking for "smythe" and when "smith" gets highlighted I type the "y" and press enter to get the then highlighted "smythe". If my control erased the initial letters, I'd start over with a new control on the form. I've had good luck using combo boxes to find and display records. Good luck. :cool: Gus Brunston
An old PICKer
padregus@home.com
 
Dear Doug:
Here's another thought. I opened a sample database that came with Access2000 called "Addrbook". In the form called "Household" in that database there is a text box for "HouseholdName". I couldn't find any code associated with it--it just works without any events defined, etc.
Maybe working with that sample (if you have it), you could solve your enter and search problem. I still like the combo box. Best of luck with your congregation list. :) Gus Brunston
An old PICKer
padregus@home.com
 
Doug:
I bet it's AUTOEXPAND, a property that you have to select as yes. Here's from HELP on that topic: (Default) Microsoft Access fills in the combo box from the list with the first value matching the first character that you type. As you type additional characters, Microsoft Access changes the value displayed to match all the characters typed
Enable that property under Data, and I'll bet that will solve your problem. Let us know. :) Gus Brunston
An old PICKer
padregus@home.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top