SteveL13
asked on
How populate a field with records from a query separated by commas
I have a form that has a sub-form. The sub-forms record source is a query and is displayed as a datasheet. But what I'm trying to do is populate a field on the main form with data from the query in the subform. But I need to populate the information as, for example, "Steve, Bill, David". In other words, the results of the query separated with a comma and a space.
So if the query looks like this:
Populate the field on the main form with "Steve, Bill, David"
So if the query looks like this:
Populate the field on the main form with "Steve, Bill, David"
ASKER
I’m not trying to populate the header. just populate a field in the detail section of the form.
You wrote:
But what I'm trying to do is populate a field on the main form with data from the query in the subform.
That seems to indicate that you are taking data from the subform (your "detail" records) and using that data to populate something in the "main" form (your "header" record).
If that's not correct, please provide examples of what you have not (i.e. the data structures, or pics of the form(s)), and what you want to do (again - pics or an excel example).
ASKER
Actually forget the sub form. I only have it on the main form temporarily to show what should concatenate in the field on the main form.
ASKER
I just want to concatenate the results of a query and display the concatenation in the field.
ASKER
as demonstrated in the picture I posted.
Use the DConcat code from Patrick Matthews
https://www.experts-exchange.com/articles/2380/Domain-Aggregate-for-Concatenating-Values-by-Group-in-Microsoft-Access.html
https://www.experts-exchange.com/articles/2380/Domain-Aggregate-for-Concatenating-Values-by-Group-in-Microsoft-Access.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You'd have to concatenate those values together if you want them to appear as a comma separated value in your main form.
What's the reason for populating data in the record's header, using data in the record detail section? Sounds like your data is properly stored, and you're trying to "flatten" it.