none
insert a long text field into a combobox RRS feed

  • Question

  • Hi,

    I have a table of which one field is LONG TEXT.

    I need to insert this data into a Combobox. The data in the table is 492 characters long.

    When I try to put this field in a combo box, it displays only the first word, or first couple of words, and not the full text.

    Is there a way to display the full LONG TEXT field in the combo box?

    Thanks

    Deon

    Monday, December 4, 2017 11:55 AM

Answers

  • When you say your data type is LONG TEXT, do you mean the data type is a MEMO data type? If it is, I would forget about using a List or Combo box to select it. Just create a SubForm on your main form with the Memo field included. Then use the Master / Child property of the SubForm to link the field to the main form you have already created. That way the Memo field will show for each record in the main form. Of course you will need to include any common Primary Key in the SubForm but you can hide it if you wish. You can make the text box control in the SubForm any width and height you wish to show all the text. You can also use the Vertical Scroll bar property of the text box as well. A MEMO field can hold ~16,000 characters but you cannot use them in calculations or as filtering criteria. Do all you filtering on the main form.
    • Marked as answer by Deon SA Tuesday, December 5, 2017 7:56 AM
    Monday, December 4, 2017 4:34 PM

All replies

  • The ListWidth property of a combo box can be given a value so that it is considerably wider than the control, but the values listed would be truncated to 255 characters.  A list box, in which each value wraps over multiple lines can be simulated by means of a subform.  It might be possible to combine this with a text box as a 'hybrid' control, but this would means writing code to show/hide the subform in simulation of dropping down a combo box's list, and to insert a value into the text box when a row is selected in the subform.  It's not something I've ever tried, however, so I can't give you any indication of what such code would be like.

    You'll find an example of a simulated list box in an unbound form, in which each item in the list occupies multiple lines in 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.

    Another form in this little demo file illustrates the use of a simulated list box in a bound form.  A big drawback with this, however, is that when focus is moved to the subform to select an item, this forces the parent form's current record to be saved.  Consequently it would be necessary to ensure that all controls bound to 'required' columns have either had a value inserted, or have default value.  In my demo a default value of 'N/A' is used, but this will not always be appropriate.

    My own inclination in a situation like this, would be to have another column of short text data type in the relevant referenced table with abbreviated values from which the long text can be identified.  These values can then be listed in the combo box, and the long text value shown in a read-only text box in the form.  This could be achieved either by using an unbound text box which references the combo box to show the corresponding long text value, or, in a bound form, by binding the form to a query in which the referenced table is joined to the table into which values are inserted via the form.  The long text value can then be shown in a bound text box.


    Ken Sheridan, Stafford, England


    • Edited by Ken Sheridan Monday, December 4, 2017 1:24 PM Hyperlink added.
    Monday, December 4, 2017 1:23 PM
  • Have you tried increasing the List Width property of the combo box?

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Monday, December 4, 2017 1:27 PM
  • I don't believe text in a ComboBox can wrap so it would have to be very wide to accommodate that many characters of text. Maybe you should display it in a different control based upon the ComboBox selection.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Monday, December 4, 2017 1:55 PM
  • When you say your data type is LONG TEXT, do you mean the data type is a MEMO data type? If it is, I would forget about using a List or Combo box to select it. Just create a SubForm on your main form with the Memo field included. Then use the Master / Child property of the SubForm to link the field to the main form you have already created. That way the Memo field will show for each record in the main form. Of course you will need to include any common Primary Key in the SubForm but you can hide it if you wish. You can make the text box control in the SubForm any width and height you wish to show all the text. You can also use the Vertical Scroll bar property of the text box as well. A MEMO field can hold ~16,000 characters but you cannot use them in calculations or as filtering criteria. Do all you filtering on the main form.
    • Marked as answer by Deon SA Tuesday, December 5, 2017 7:56 AM
    Monday, December 4, 2017 4:34 PM
  • @Lawrence Ellefson: in Access 2013 and later, Memo fields are called Long Text fields, and Text fields are called Short Text fields.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Monday, December 4, 2017 5:16 PM
  • Thanks Hans...didn't know that. Same answer though.

    Monday, December 4, 2017 6:53 PM
  • Thanks Lawrence, this did the trick.
    Tuesday, December 5, 2017 7:56 AM