Feb 7 2005, 07:05 PM
At present, I've set the db property so that the cursor is at the beginning of existing text when entering a textbox.
I find that some users may just tap a key and remove all the existing text!
But on boxes where I do want to highlite the existing text, is there anything simple to use? I've been reading about Sel properties in VB Help but I can't seem to see which one will simply highlight the text?
Feb 7 2005, 07:29 PM
Not quite sure what you want to do... Tabbing into a control that has data will highlight the control and any keypress will deleted the existing (highlighted) data and enter the key pressed.
Can you be more specific in what it is you are trying to accomplish and I am sure that someone here will have an answer for you.
Feb 7 2005, 07:52 PM
I want to use VB to highlight existing text in a textbox when I want to . . . using VB . . . since I've set the db default to just place the cursor at the beginning of any textbox upon entry.
I probably will use the On Exit event of the control ahead of the control (on the tab list) that I wish to highlight all the text.
Feb 7 2005, 08:03 PM
What event did you use to set the dafault to just place the cursor at the beginning of the control? How are you moving between records now? If you have a form that is bound to a table and the form is showing an existing record then tabbing into a field will highlight the field. I do not understand what you want to do with VB because you do not need code to highlight the text in the control.
I am missing something here and I am not sure what.... My apologies for being so thick....
Feb 7 2005, 08:18 PM
Don't worry about it Jack . . . I've layed off Access for a bit so I'm trying to remember the 'tricks' I used to know . . .
The users just tab or hit enter to move to each control on a bound form.
I set the overall cursor properties for the db under 'options/keyboard/behavior entering a field' such that entering a control on a bound form puts the cursor at the beginning of the text (go to start of field) . . . so they don't wipe out the existing entry . . . a problem with new db users.
But on some textboxes, I do want to highlight the text so they can just begin typing over without using the backspace keys . . . (select entire field). thus, on the control prior to, I can use the On Exit even to 'select entire field' only on the controls I wish to.
Feb 7 2005, 08:55 PM
If you sometiimes want to highlight the data then use code like this in the On Enter event of the control
Me.ControlName.SelLength = Len(Me.ContolName)
Feb 7 2005, 09:25 PM
Feb 8 2005, 11:03 AM
You are welcome and continued success with your project....
Feb 28 2005, 08:07 PM
I've used the code you've given me and it works fine in most cases.
But when I try to highlite a number, the highlite stops and thus doesn't highlite the entire number like: $7,900.00
Only the '$7,9' gets highlited leaving the '00.00' un-highlited.
The textbox is bound to a currency field with no format specified on the control.
Is this just a limitation since the number isn't a 'true' string?
Feb 28 2005, 08:33 PM
This is a long way round but it works. I am sure the code can be shortened but I am short on time...
Dim L As Integer
Dim S As String
S = Format(Me.MyCurrencyField, "Currency")
L = Len(S)
Me.MyCurrencyField.SelLength = L
Feb 28 2005, 08:42 PM
Me.MyCurrencyField.SelLength = Len(Format(Me.MyCurrencyField, "Currency"))
Feb 28 2005, 08:49 PM
That's the one! Brain is toast this afternoon so thanks for steppng in with the right answer! (And I have NOT had a single glass of wine.....yet...)
Mar 1 2005, 05:59 PM
Thanks! Works like a charm . . . and it's so great to have a forum when you can pick people's brains on things like this that would take forever to figure out on your own . . . wow!
Mar 1 2005, 06:04 PM
All the credit goes to Ricky on this one as I couldn't pull it together... We are glad you like the forum well enough to become a member.... You are part of the reason we are Number One so thank you!
Jack... with kudos to Mr. Hicks
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here