• Concatenating multiple records into a single text box

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Concatenating multiple records into a single text box

    Author
    Topic
    #484166

    I have been modifying the Access 2007 downloadable “incident database” for use as a logging tool. Within this, each incident has a “Comment” field, which is a Memo box set to “Append After”, and the details form then uses the ColumnHistory() function to show the history of the comments added. This works just fine.

    Now, I have had feedback from users. They want a space between each piece of history, to make it more readable, and they would like to see the most recent history item first. In the context in which they are using it, this makes more sense. However, I have satisfied myself that neither of these are possible with the ColumnHistory() function.

    The better way to do this is to therefore to create a table with comments and to write a query to return all of the comments related to a particular issue, sorted with the most recent first. This is quite straightforward.

    What doesn’t appear to be straightforward, though, is displaying this in the form. I would rather put the data into a text box than into a datasheet, simply because the comments will be of variable width and it will be more readable that way. But I cannot see how to get multiple records to concatenate into a single text box. How should I do this?

    Thanks.

    Stuart

    Viewing 2 reply threads
    Author
    Replies
    • #1339265

      I may have thought of a solution, since this box only needs to be filled once on Form Open. Would this work:

      In Form Open event:

      Set a new recordset to be equal to the results from the query
      For each record in recordset
      Add comment to a string, with suitable padding
      Next
      Set textbox value to string

      My only worry would be whether I would hit a character limit for the text box? I think that you are only allowed 255 characters, aren’t you?

    • #1339348

      The text box itself has no size limit. If you choose Memo for the field that will hold the data, you will be able to store up to 65,536 characters.

    • #1339640

      And don’t use padding. Use vbCrLf to start the next comment on a new line. Or two of them to have a separator line.

    Viewing 2 reply threads
    Reply To: Concatenating multiple records into a single text box

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

    Your information: