Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

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:

User generated image
Populate the field on the main form with "Steve, Bill, David"
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

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.

Avatar of SteveL13

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).



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.
I just want to concatenate the results of a query and display the concatenation in the field.
as demonstrated in the picture I posted.
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial