Concatenate Comment Rows

SeanCly10

New member
Local time
Today, 14:47
Joined
Apr 26, 2012
Messages
7
Hi all,

I'm not sure if this part of the forums is the place for this question, but here goes anyway.

I am trying to concatenate a series of sequentially numbered comment fields contained in a single table. It looks like this:

71478 1 I want to
71478 2 combine all
71478 3 of these lines
71478 4 into the same
71478 5 field so
71478 6 a person can
71478 7 read it

I'm pretty certain I need VB code, but how to write it is still a little beyond me. Can someone give me some pointers?

Thank you,
Sean
 
Have a look at Allen Browne's Concatenate function.
 
Hey, it worked pretty good! Thanks!

One other thing, though: for comment series where there is 10 or more, the code tries to put 10 immediately after 1. I know this is a basic Access issue and not a problem of the function, but might someone know how to make the thing properly order the numbers?
 
It sounds like that sorting field is text rather thn numeric. If so, you can either change it or force it in your function with CInt().
 
Well, I knew it was too good to be true.

The table I'm working with has multiple accounts in it, each with multiple comment lines. The function will concatenate the comment fields, sure, but it only does it for the first one and puts that result in the field for each account, and not just the related one; i.e., Account A's comment is reproduced in the comment field of Accounts B, C, and D, as well as A.

Am I missing something?
 
Your SQL would need to restrict to a given account. I'm sure both of the functions posted allowed for that.
 
They probably do, but I can't figure out how to alter them to do it. I keep getting the same result, one combined comment field repeated for every account.
 
We're flying blind here. Maybe you can post the db here, or at least the code and how you're calling it?
 
Okay. I'm using the Concatenate function that Beetle posted.

Here is the (greatly simplified) SQL for the query:

SELECT ConcatRelated("RMSTRXNOTE","TestTable","RMSFILENUM = left(SEQUENCE,6)","SEQUENCE","") AS Expr1
FROM TestTable;

TestTable.xls is the entry data. the column of SEQUENCE is an attempt to make each line truly unique - including the file number, transaction date and time, plus the sequence number. TestTable_Result.xls is the result of the query.
 

Attachments

Does this work?

SELECT ConcatRelated("RMSTRXNOTE","TestTable","RMSFILENUM = '" & [RMSFILENUM] & "'","SEQUENCE","") AS Expr1
FROM TestTable;
 
By the way, I suspect you'd actually want something like this:

SELECT TestTable.RMSFILENUM, ConcatRelated("RMSTRXNOTE","TestTable","RMSFILENUM = '" & [RMSFILENUM] & "'","SEQUENCE","") AS Expr1
FROM TestTable
GROUP BY TestTable.RMSFILENUM;
 

Users who are viewing this thread

Back
Top Bottom