Cursor position in text box
Author |
Message |
Alex Dybenk #1 / 10
|
 Cursor position in text box
Hello, is it available to get current cursor position in Access 97 text field? .SelStart works only if i select at least one character in text box, otherwise it returns 0. I need this to build something like Access expression builder. -- Best regards, ___________ Alex Dybenko Point Limited
Home Page: http://www.*-*-*.com/ Moscow MS Access User Group, chairman http://www.*-*-*.com/
|
Fri, 14 Jul 2000 03:00:00 GMT |
|
 |
Andy Bar #2 / 10
|
 Cursor position in text box
Hi Alex, SelStart works even if no text is selected. To prove this, try inserting the following code behind a textbox, and click into existing text: Private Sub Text2_Click() MsgBox "SelStart: " & Me!Text2.SelStart End Sub If, for example the textbox contains "abcd" and you click between the b and c, the message will read, "SelStart: 2". So there must be something else going on if you are getting only zero values. -- Andy Quote:
>Hello, >is it available to get current cursor position in Access 97 text field? >.SelStart works only if i select at least one character in text box, >otherwise it returns 0. >I need this to build something like Access expression builder. >-- >Best regards, >___________ >Alex Dybenko >Point Limited
>Home Page: http://www.geocities.com/SiliconValley/Heights/5091/ >Moscow MS Access User Group, chairman >http://www.arimsoft.ru/msaccess
|
Fri, 14 Jul 2000 03:00:00 GMT |
|
 |
Terry Wickende #3 / 10
|
 Cursor position in text box
Andy/Alex You get a value of Zero for SelStart when no text is selected and the cursor is in front of the first character OR the highlighted text starts with the first character. Hope this helps Terry
Quote: > Hi Alex, > SelStart works even if no text is selected. To prove this, try > inserting the following code behind a textbox, and click into existing > text: > Private Sub Text2_Click() > MsgBox "SelStart: " & Me!Text2.SelStart > End Sub > If, for example the textbox contains "abcd" and you click between the > b and c, the message will read, "SelStart: 2". > So there must be something else going on if you are getting only zero > values. > -- Andy
> >Hello, > >is it available to get current cursor position in Access 97 text field? > >.SelStart works only if i select at least one character in text box, > >otherwise it returns 0. > >I need this to build something like Access expression builder. > >-- > >Best regards, > >___________ > >Alex Dybenko > >Point Limited
> >Home Page: http://www.geocities.com/SiliconValley/Heights/5091/ > >Moscow MS Access User Group, chairman > >http://www.arimsoft.ru/msaccess
|
Fri, 14 Jul 2000 03:00:00 GMT |
|
 |
Alex Dybenk #4 / 10
|
 Cursor position in text box
Hi Andy, thank you, it really works but how to determine SelStart, when you loose focus from this field? I tried both onExit and OnLostFocus, SelStart returns only 0 for example i have a text box and button on same form, i set cursor somewhere in the text box, and then, when i press button i need to insert there any text To catch all text box events (on change, on click, etc.) and then use the last SelStart? Maybe there is an easy way? Best regards, ___________ Alex Dybenko Point Limited
Home Page: http://www.geocities.com/SiliconValley/Heights/5091/ Moscow MS Access User Group, chairman http://www.arimsoft.ru/msaccess Quote:
>Hi Alex, >SelStart works even if no text is selected. To prove this, try >inserting the following code behind a textbox, and click into existing >text: >Private Sub Text2_Click() > MsgBox "SelStart: " & Me!Text2.SelStart >End Sub >If, for example the textbox contains "abcd" and you click between the >b and c, the message will read, "SelStart: 2". >So there must be something else going on if you are getting only zero >values. > -- Andy
>>Hello, >>is it available to get current cursor position in Access 97 text field? >>.SelStart works only if i select at least one character in text box, >>otherwise it returns 0. >>I need this to build something like Access expression builder. >>-- >>Best regards, >>___________ >>Alex Dybenko >>Point Limited
>>Home Page: http://www.geocities.com/SiliconValley/Heights/5091/ >>Moscow MS Access User Group, chairman >>http://www.arimsoft.ru/msaccess
|
Sat, 15 Jul 2000 03:00:00 GMT |
|
 |
Andy Bar #5 / 10
|
 Cursor position in text box
Here are the rules you will have to work with, Alex: If the textbox is updated, then the BeforeUpdate and AfterUpdate events will give you the correct selstart, but the Exit and LostFocus events will give you zero. If the textbox is not updated, then the BeforeUpdate and AfterUpdate events will not fire and the Exit and LostFocus events will give you the correct selstart. Hope that helps. It is an interesting problem. -- Andy Quote:
>Hi Andy, >thank you, it really works >but how to determine SelStart, when you loose focus from this field? >I tried both onExit and OnLostFocus, SelStart returns only 0 >for example i have a text box and button on same form, i set cursor >somewhere in the text box, and then, when i press button i need to insert >there any text >To catch all text box events (on change, on click, etc.) and then use the >last SelStart? >Maybe there is an easy way? >Best regards, >___________ >Alex Dybenko >Point Limited
>Home Page: http://www.geocities.com/SiliconValley/Heights/5091/ >Moscow MS Access User Group, chairman >http://www.arimsoft.ru/msaccess
>>Hi Alex, >>SelStart works even if no text is selected. To prove this, try >>inserting the following code behind a textbox, and click into existing >>text: >>Private Sub Text2_Click() >> MsgBox "SelStart: " & Me!Text2.SelStart >>End Sub >>If, for example the textbox contains "abcd" and you click between the >>b and c, the message will read, "SelStart: 2". >>So there must be something else going on if you are getting only zero >>values. >> -- Andy
>>>Hello, >>>is it available to get current cursor position in Access 97 text field? >>>.SelStart works only if i select at least one character in text box, >>>otherwise it returns 0. >>>I need this to build something like Access expression builder. >>>-- >>>Best regards, >>>___________ >>>Alex Dybenko >>>Point Limited
>>>Home Page: http://www.geocities.com/SiliconValley/Heights/5091/ >>>Moscow MS Access User Group, chairman >>>http://www.arimsoft.ru/msaccess
|
Sat, 15 Jul 2000 03:00:00 GMT |
|
 |
Alex Dybenk #6 / 10
|
 Cursor position in text box
Andy, thank you very much! i forgot about these events Now i have solved this Alex Quote:
>Here are the rules you will have to work with, Alex: >If the textbox is updated, then the BeforeUpdate and AfterUpdate >events will give you the correct selstart, but the Exit and LostFocus >events will give you zero. >If the textbox is not updated, then the BeforeUpdate and AfterUpdate >events will not fire and the Exit and LostFocus events will give you >the correct selstart. >Hope that helps. It is an interesting problem. > -- Andy
|
Sat, 15 Jul 2000 03:00:00 GMT |
|
 |
Terry Kref #7 / 10
|
 Cursor position in text box
Use a variable to hold the value of Selstart.
Quote: >Hi Andy, >thank you, it really works >but how to determine SelStart, when you loose focus from this field? >I tried both onExit and OnLostFocus, SelStart returns only 0 >for example i have a text box and button on same form, i set cursor >somewhere in the text box, and then, when i press button i need to insert >there any text >To catch all text box events (on change, on click, etc.) and then use the >last SelStart? >Maybe there is an easy way? >Best regards, >___________ >Alex Dybenko >Point Limited
>Home Page: http://www.geocities.com/SiliconValley/Heights/5091/ >Moscow MS Access User Group, chairman >http://www.arimsoft.ru/msaccess
>>Hi Alex, >>SelStart works even if no text is selected. To prove this, try >>inserting the following code behind a textbox, and click into existing >>text: >>Private Sub Text2_Click() >> MsgBox "SelStart: " & Me!Text2.SelStart >>End Sub >>If, for example the textbox contains "abcd" and you click between the >>b and c, the message will read, "SelStart: 2". >>So there must be something else going on if you are getting only zero >>values. >> -- Andy
>>>Hello, >>>is it available to get current cursor position in Access 97 text field? >>>.SelStart works only if i select at least one character in text box, >>>otherwise it returns 0. >>>I need this to build something like Access expression builder. >>>-- >>>Best regards, >>>___________ >>>Alex Dybenko >>>Point Limited
>>>Home Page: http://www.geocities.com/SiliconValley/Heights/5091/ >>>Moscow MS Access User Group, chairman >>>http://www.arimsoft.ru/msaccess
|
Sat, 15 Jul 2000 03:00:00 GMT |
|
 |
Alex Dybenk #8 / 10
|
 Cursor position in text box
Thanks, Terry, I use a variable to hold the value of Selstart from afterupdate or exit events, depending on last operation with this field. So the problem is solved! Another question: Access automatically trims spaces (chr$(32)) at the end of the field. Is it available to switch off this feature? for example, if i type, without quotes, "Hello ", the field will be "Hello" Alex Quote:
>Use a variable to hold the value of Selstart.
|
Sun, 16 Jul 2000 03:00:00 GMT |
|
 |
Terry Kref #9 / 10
|
 Cursor position in text box
Hi Alex I take it that what is happening is that you type into the text box, move away to add something and then wen you move back the trailing space has been trimmed, there's a couple of ways around that; 1) When ever you return to the box append a space to it. 2) Whenever you leave the box store it's text in a variable and then restore the text when you return. I wrote a similar system for a report wizard addin that I created, I seem to remember that I used a combination of the two options depending upon the .SelStart position relative to the length of the field. that is if the .SelStart was equal to the length I used option 1, if it was not equal I used option 2. I also did some other tests such as was the last character a ( or a [, and so on. It worked out reasonably well in the end. Quote:
>Thanks, Terry, >I use a variable to hold the value of Selstart from afterupdate or exit >events, depending on last operation with this field. >So the problem is solved! >Another question: >Access automatically trims spaces (chr$(32)) at the end of the field. Is it >available to switch off this feature? >for example, if i type, without quotes, "Hello ", the field will be >"Hello" >Alex
>>Use a variable to hold the value of Selstart.
|
Sun, 16 Jul 2000 03:00:00 GMT |
|
|
|