×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

All text selected when clicking Tab Control

All text selected when clicking Tab Control

All text selected when clicking Tab Control

(OP)
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?

RE: All text selected when clicking Tab Control

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

RE: All text selected when clicking Tab Control

(OP)
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.

RE: All text selected when clicking Tab Control

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

RE: All text selected when clicking Tab Control

It is the default behaviour for SetFocus for text controls in Access

RE: All text selected when clicking Tab Control

Quote (TrekBiker)

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.

RE: All text selected when clicking Tab Control

>Do you have several text boxes on the tab
> each with a single field
Suggests a single textbox ...

RE: All text selected when clicking Tab Control

(OP)
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 

RE: All text selected when clicking Tab Control

>the texts they contain don't get highlighted when swapping from one to the other

It'll depend on the Tab Index order

RE: All text selected when clicking Tab Control

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.

RE: All text selected when clicking Tab Control

(OP)
Andy, yes use Shipping tool all the time but starting it removed the highlight I was asking about. Hence use of phone, sorry.

RE: All text selected when clicking Tab Control

> removed the highlight

Odd. Works fine here without removing the highlight … oh well.

RE: All text selected when clicking Tab Control

There is always a PrintScreen or Alt-PrintScreen

Just a suggestion... smile


---- Andy

There is a great need for a sarcasm font.

RE: All text selected when clicking Tab Control

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close