• Show more than 1 record in a text box (97/2K)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Show more than 1 record in a text box (97/2K)

    Author
    Topic
    #380016

    I have an unbound text box on a form which displays the treatment history obtained by a query. However, when the query contains more than 1 value, only the first value is displayed.
    How can I display all values or do I need to use a different method?

    Rob

    Viewing 1 reply thread
    Author
    Replies
    • #634741

      Hi Rob,

      You can use several techniques to accomplish this. Perhaps the easiest is to use a List box instead of a Text box. Make sure it’s unbound and then set its row source to the desired query.

      If you must use a text box, you’ll need to use code. You’ll want to use either ADO or DAO to loop through a recordset (based on the query) and add the value to a string variable. Then, assign the string to the textbox’s value property. You’ll probably want to use comma or semicolon to separate the items. Post back if you decide to do it this way and need help.

      Hope this helps!

      • #634743

        Thanks Mark for the quick reply and offer of further help. I would imagine that the list box option would require the user to click the arrow to view the list. While this is perfectly acceptable, if a box could show a list of previous treatments without further input from the user, it would be more aesthetically pleasing. Also it would challenge and inform me. If you would expand on your second option, I would be extremely grateful.

        Rob

        • #634745

          I think you’re mistaking a Listbox for a Combo Box (or drop-down). The list box is a fixed size and does not drop down. This is probably your best bet.

          Although, John’s suggestion of a continuous subform is also a great idea – why didn’t I think of that smile

          Post back if you need further assistance.

          • #634747

            Good grief! That was quick.
            Thanks Mark and John.
            Yes Mark, I was confused but shouldn’t have been. And John, I had played with the subform idea but I couldn’t quite get it right.
            Perhaps you could help with both ideas in order to further my education.
            Secondly, if you could take a look at my previous post (200965) regarding the mysterious behaviour of a subform, my grate will never be so full.

            Many thanks,

            Rob

            • #634752

              Rob
              I have posted a rely to your other post, and it may help you work out what is wrong with your history subform too.

    • #634742

      Another option is to put the textbox into a small continuous subform. This will be able to show all the relevant entries from the history.

    Viewing 1 reply thread
    Reply To: Show more than 1 record in a text box (97/2K)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: