Scroll bars in a text box

or, perhaps a little more obvious, colour up the border if over a certain length

Peter
 
In stead of using a normal text box, I tried with a "Microsoft Forms 2.0 ActiveX text box" control. When using this control, the scrollbar is visible when there is data in the text box, even if it doesn't have the focus.
Thanks for your help anyway.
 
[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!

- Dayton - Thu. 07/25/2013 @ 11:14:08
 
Ok ... so this post is really old, but I thought I would share my suggestion which doesn't require much code. I had the same issue in Access 2010 (they still haven't fixed this yet) where the vertical scroll bars don't appear in a text box unless it has the focus in a form.

To help show that there is more text I use an Unbound text box and set the Default Value to be "More▼". I set the font to be 7 so that it is very small and allows for the unbound text box to be placed in the bottom right corner of the Text Box that could have additional text that is not visible. Then, using the Conditional Formatting for the new unbound text box, I use the Expression Is option to reference the Text Box that could contain more text than visible and build a formula to determine if it contains under a certain amount of characters. If the Text Box does contain less than a certain number of characters, I set the background and font colors of the Unbound text box to be the same as the background of the Text Box (so it will look like it isn't there). Make sure to set the Unbound text box to be Locked so that users don't click on it for editing.

In one of my forms that I needed this, I was using the CHR(26) to seperate each line so I was able to use an expression like so to determine if the Text Box (Prog in this example) had less than 4 instances of the special character, which would fit in my Text Box. Here is the expression example:

(Len([Prog])-Len(Replace([Prog],Chr(26),"")))<4

This worked like a charm for me in that it would display in the bottom right of the Text Box when there is more text to be shown and when the user clicks into the Text Box, they are then provided the scroll bar. Since I was using a Continuous Form, it worked out well in that only the records that had more text than could be shown would display the "More▼" text in the bottom right of the Text Box.

UPDATE: I added a picture of how I am using the above solution.

You may need to play around with your expression, but this seemed to be the simplest way to get some means of identifying a text box could have additional text to be read. Hope this can help someone else down the road. Good Luck! :cool:
 

Attachments

  • Example.JPG
    Example.JPG
    18.8 KB · Views: 255
Last edited:
The logic is simple, if you have a text box that has "This is OK However don't do it" and you glance at it, it may just show "This is OK", a scroll bar would reveal there is more than meets the eye;)
 

Users who are viewing this thread

Back
Top Bottom