07-01-09, 20:33 #1Registered User
- Join Date
- Nov 2002
Unanswered: Combo Box Text Highlighting Like Tab
I have been looking for an answer to this in the help and online, but have been unable to find it. I would like to make the combo boxes in my application act friendlier. If you tab (or enter if you have that act like a tab) into a combo box it highlights the value there, and if you start to type a different value it replaces the old value there and autoexpands to that value if it exists in the list. But, if a user places their mouse in that field and clicks into it, it more than likely places the cursor in the middle of the displayed value, and any typing yields gibberish as it becomes the desired value wrapped in two halves of the previous value. I can't for the life of me find a way to emulate vb.net's selectall functionality so that the user doesn't have to double-click the field to try to select the entire contents before typing a new value. This is especially annoying on the pop-up forms that I use to allow the users to open reports subject to the values entered on the controls on that form. I thank you in advance for your help and your time.
07-01-09, 21:33 #2Moderator
- Join Date
- Dec 2004
- Madison, WI
You can autoexpand the combobox in the OnFocus (or OnEnter) event of the combobox field.
or you can also set the cursor to the beginning of the combobox in the OnFocus event (should work for comboboxes like text boxes)...
Private Sub txtYourTextBox_GotFocus()
Me.txtYourTextBox.SelStart = 1 (or =0 depending on how your combobox is configured)
One of the above or possibly a combination should do what you want it to do.
Another thing I do with comboboxes is that I may set it "Limit to List" = true and then write some code in the "Not in List" event
Response = acdataerrcontinue
msgbox "Must match in the listing." (or open form to add new record or prompt user if they want to save new value.)
me!myComboboxName = null
FYI - To set the cursor to the end of the field...
Private Sub memPropertyNotes_Enter()
Me!memPropertyNotes.SelStart = Me!memPropertyNotes.SelLength
Last edited by pkstormy; 07-01-09 at 21:45.Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)
07-01-09, 21:55 #3L33t Helpa Munky
- Join Date
- Nov 2007
- Adelaide, South Australia
Train the user to TAB instead of click? That's what I do. Users quickly get used to it.Owner and Manager of
CypherBYTE, Microsoft Access Development Specialists.
Microsoft Access MCP.
And all around nice guy!
"Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
"...teach a man to code and he'll be frustrated for life! " -- georgev