Always show scrollbar in text box

G

Guest

Hi, I have a text box with verticle scrollbars enabled but you can only see
the scrollbar when the text box has focus. How can I make it show the
scrollbar all the time?
 
Joined
Jul 25, 2013
Messages
1
Reaction score
0
[Yes, I know I'm replying to an old thread, but I haven't found the solution mentioned elsewhere, so I figured I'd chime in here.]

I feel your pain man. I have pop-up screens to help users with explanatory text, and there's no "normal" way to get the textbox to show that there's more text there than is displayed because the scroll bar ONLY appears when a user physically clicks on the text box itself.

The good news is that it CAN be done, sort of, it's just a pain in the butt. Here's how:

First, use DoCmd.GoToControl to activate your text box. When you do this, the text will be highlighted/selected, but the text cursor will still not actually be "in" the text box. The scroll bar will show, but with everything highlighted, it's pretty ugly.

To de-highlight/deselct the text, you can use SendKeys. Now if you use simple arrow keys, since the cursor's not actually "in" the text box at this point, it will just move the focus to the next/previous control in the Tab sequence. You have to trick it into thinking you're wanting to select text. I use SHIFT+RIGHT, which is one of the "Extend Selection" keys. That puts the cursor officially "in" the text box, since it thinks your changing the selection area. Then you can send a HOME keystroke to actually sent the cursor to the HOME position.

It's silly, but it works! (Caveat - It works in Access 2010!)

So here's the code. In this example, the text box name is "txtHelpBox". The code goes into the Form_Open event:
DoCmd.GoToControl Me.txtHelpBox.Name
SendKeys "+{Right}{Home}"

It's amazing what you can do if you're just willing to throw logic to the winds!

Happy coding! :cheers:

- Dayton - Thu. 07/25/2013 @ 10:43:56
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top