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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

All text selected when clicking Tab Control 1

Status
Not open for further replies.

TrekBiker

Technical User
Nov 26, 2010
330
GB
A tab control on a client's form has three pages, each with a single field. When clicking the headers to move from tab to tab all of the existing text on the selected tab is highlighted automatically. Can I stop this?

 
Have you confirmed there is no code running that might run sendkeys to select all? Typically clicking to a different tab will put the cursor in one control.

You may need to repair and compact.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Sorry for late reply, skiing trip intervened.

No code running to cause this. Seems to be an inbuilt feature because the fields I moved to the tab control pages didn't show the same behaviour when on the form itself.
 
I don't think this has anything to do with tabs. Anytime you move from one control to another the entire contents of the control are selected. You can add code to the Got Focus to position the cursor at the beginning or end of the text.

Check out the .SelStart method.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
It is the default behaviour for SetFocus for text controls in Access
 
TrekBiker said:
all of the existing text on the selected tab is highlighted automatically

You may want to be more precise - what text is highlighted? Do you have several text boxes on the tab and all text in all textboxes is highlighted? A picture here would go a long way presenting your issue...


---- Andy

There is a great need for a sarcasm font.
 
>Do you have several text boxes on the tab
> each with a single field
Suggests a single textbox ...
 
Thanks to all.

This does seem to be a default behaviour. When the fields are in the normal form the texts they contain don't get highlighted when swapping from one to the other. When moved to the Tab Control pages, one field per page, they show the behaviour - specifically the default page isn't highlighted but going to another page does show the highlighting. Hope this is clear in the attachment (thanks Andy, didn't know I could do this - if it works).

Thanks to dhookom for pointing to the .SelStart method, which led me to adding Got Focus events to each field on the Tab Control pages, like this example. Works a treat.

Code:
Private Sub ContactInformation_GotFocus()

    If Nz(Me.ContactInformation, "") = "" Then
         Me.ContactInformation.SelStart = 0
    Else
         Me.ContactInformation.SelStart = Len(Me.ContactInformation) + 1
    End If

End Sub
 
 https://files.engineering.com/getfile.aspx?folder=46c20825-48ba-4ae7-a6f2-3c2a3b2140c2&file=Tab_Control.jpg
>the texts they contain don't get highlighted when swapping from one to the other

It'll depend on the Tab Index order
 
Interesting picture, with your phone of your screen (I guess...?)
Have you used a Snipping Tool in Windows?


---- Andy

There is a great need for a sarcasm font.
 
Andy, yes use Shipping tool all the time but starting it removed the highlight I was asking about. Hence use of phone, sorry.
 
> removed the highlight

Odd. Works fine here without removing the highlight … oh well.
 
There is always a PrintScreen or Alt-PrintScreen

Just a suggestion... :)


---- Andy

There is a great need for a sarcasm font.
 
Just to clarify in words what was happening from what I can tell looking at the picture...

There is a tab control with tabs each having one textbox on it. When the tab was changed, all the text in the only control was selected which is the same as the first control in the tab order which is the default. Personally I had never run across or needed selstart... good to know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top