none
Listbox with long text, but no horizontal scroll bar. RRS feed

  • Question

  • Hey guys, I have a listbox with some long text on a single column. I want my users to be able to see the whole text. I know listboxes don't support the textwrap option, but it would be great if I could at least have them scroll to read the whole sentence. Any thoughts?
    Monday, September 2, 2019 1:54 AM

Answers

  • You might like to take a look at DummyList.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to  amend the form design accordingly.  

    If you have difficulty opening the link, copy the link (NB, not the link location) and paste it into your browser's address bar.

    This little demo file illustrates ways of simulating a list box with a subform, including one example with multi-line rows.  The drawback of this, however, is that the height of each row is fixed, so rows with shorter text have a blank second line.  The subforms in the demo are set to have a vertical scroll bar only, but will allow horizontal scrolling also if the ScrollBars property of the subform is set to both.

    Ken Sheridan, Stafford, England

    • Marked as answer by InnVis Wednesday, September 4, 2019 12:10 PM
    Monday, September 2, 2019 10:12 PM
  • Hi InnVis,

    Since you are trying to use a List box control (which is not editable) I believe the simplest method to do what you want is to embed a Report object in the Form (a bit like a sub-form) and just make sure that the Can Grow properties of the Detail section and relevant Text boxes are set to Yes, Access will then do the rest for you (see screen shot below).

    Peter Hibbs.

    • Marked as answer by InnVis Thursday, September 5, 2019 10:27 AM
    Thursday, September 5, 2019 10:22 AM

All replies

  • you could have a multiline textbox with a ControlSource of:

    =mylistbox.column(x)


    -Tom. Microsoft Access MVP

    Monday, September 2, 2019 3:28 AM
  • Hi,

    If Tom's suggestion didn't work. Try this.

    Another neat trick is to add another column.

    Listbox Properties

    Format Tab – Column Count = 2

    Format Tab –­­­ Column Width = 3”;0.5”

    Data Tab – Row Source =

    Something like

    “SELECT FirstColumn, IIf(Not IsNull([Company]![Building]),"","") AS SecondColumn FROM MyTableName;

    Not perfect, but at least it will show the Horizontal Bar of your ListBox.

    The trick is to blanked the second column so that it will not confused the Users.

    ListBox will only show the Horizontal Bar if there are 2 or more Columns.

    Monday, September 2, 2019 4:13 AM
  • Well probably you could get around by using  a small continuous form instead of the listbox ..careful placement and size will give something similar to listbox.
    Monday, September 2, 2019 5:13 AM
  • Hey! I tried this initially and yes it does show the Horizontal Bar, but it's useless because it does not continue displaying the information of the first items (no matter how large you make that column). The only way really is to stretch the list so much so that it looks ridiculous.
    Monday, September 2, 2019 6:09 AM
  • This is sort of brilliant. Let me mess around with this to see if I get the esthetics I'm looking for. Thanks!

    Monday, September 2, 2019 6:10 AM
  • OK, so I tried making the textbox multiline by selecting the "New Line In Field" on the other tab, but it won't display each line on that textbox's record. It will only display the line I have selected. Thoughts?
    Monday, September 2, 2019 6:23 AM
  • Hi,

    It's not possible even with a subform. No way, since the Horizontal Bar scrolling is Column by Column. Not a Browser scroll or any application smooth scrolling.

    To use a subform as or like a Listbox, that gonna be real tricky.

    Only Textbox has a Height property. (I'm not sure about newer version of Access for Listbox Row/Column Height and Row Height of a subdata sheet view.)

    You could use the RecordsetClone of the subform to control the height of the Textbox with the in-built functions like Len() to count and increase the Textbox height accordingly. (use the same method as suggested to show a blank column for the RowSource.)

    There is no smooth scroll but the above method will show full length of text if it is acceptable. That is to say, use the subform as a Continuous Form that looks like a Listbox.

    Monday, September 2, 2019 7:31 AM
  • My suggestion on the subform is that would give the horizontal scrollbar...

    Monday, September 2, 2019 8:01 AM
  • I have a listbox with some long text on a single column. I want my users to be able to see the whole text.

    Hi InnVIs,

    As with many things in Access, I work quite differently.

    I do not use Listboxes, but instead a dynamic form with (normal) controls. For each control on any form I can zoom the value of the control in Zoom-form, to display all the lines. This Zoom-form has all kind of necessary or funny functionality that works on the text. E.g. convert selected parts to Upper/Lower case, count total characters, show ASCII-values, etc. But this will not be of much help for you.

    But perhaps this can help you a little bit. When I enter any control, the StatusBarText property of that control is set to the cpntrol's value. When the control itself is not wide enough, you can at least see a little more on the StatusBer. The StatusBar though can only hold a maximum of 255 characters. I thought Listboxes also have the StatusBarText property.

    Imb.

    Monday, September 2, 2019 8:19 PM
  • You might like to take a look at DummyList.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to  amend the form design accordingly.  

    If you have difficulty opening the link, copy the link (NB, not the link location) and paste it into your browser's address bar.

    This little demo file illustrates ways of simulating a list box with a subform, including one example with multi-line rows.  The drawback of this, however, is that the height of each row is fixed, so rows with shorter text have a blank second line.  The subforms in the demo are set to have a vertical scroll bar only, but will allow horizontal scrolling also if the ScrollBars property of the subform is set to both.

    Ken Sheridan, Stafford, England

    • Marked as answer by InnVis Wednesday, September 4, 2019 12:10 PM
    Monday, September 2, 2019 10:12 PM
  • I like your demo, although I can't seem to figure out how to add text wrapping to the textbox.

    Wednesday, September 4, 2019 3:31 AM
  • I like your demo, although I can't seem to figure out how to add text wrapping to the textbox.

    It's simply a matter of setting the height of the text box in the subform so that it can accommodate however many lines are anticipated as necessary to show the longest value you anticipate.  This is the drawback of this approach; however short a value night be the text box will always be the same size, leaving empty space below any short text.  In my demo it's only sized to allow two lines, so the effect is small, but if more lines are necessary, and hence a deeper text box, and the length of the values varies significantly, it could look rather untidy.


    Ken Sheridan, Stafford, England

    Wednesday, September 4, 2019 11:06 AM
  • Do you have any ideas to at least set the vertical alignment to show single and perhaps double lined items in the center of the large textbox?
    Wednesday, September 4, 2019 3:07 PM
  • Do you have any ideas to at least set the vertical alignment to show single and perhaps double lined items in the center of the large textbox?
    I'm afraid not.

    Ken Sheridan, Stafford, England

    Wednesday, September 4, 2019 3:53 PM
  • Do you have any ideas to at least set the vertical alignment to show single and perhaps double lined items in the center of the large textbox?

    Hi InnVis,

    There is a way to adjust the size of a control according to the number of new lines, and the length of the text per line. But it is not applicable for continuous forms.

    It is quite an organization in relation to other controls, but if you like using VBA it is doable.

    Have fun!

    Imb.

    Wednesday, September 4, 2019 4:00 PM
  • Hi InnVis,

    Since you are trying to use a List box control (which is not editable) I believe the simplest method to do what you want is to embed a Report object in the Form (a bit like a sub-form) and just make sure that the Can Grow properties of the Detail section and relevant Text boxes are set to Yes, Access will then do the rest for you (see screen shot below).

    Peter Hibbs.

    • Marked as answer by InnVis Thursday, September 5, 2019 10:27 AM
    Thursday, September 5, 2019 10:22 AM
  • Thanks for this! I will see if I can combine Ken's continuous form features with this report method to create a cleaner dynamic list form.
    Thursday, September 5, 2019 10:29 AM