Seperate query results with a comma

M

Michael

I have a report that requires a summary of the country of manufacture of the
items contained therein. Sometimes I have only 1 country and it works fine.
When I have multiple countries, I need to take the results and put them in 1
field so it appears on the report like: "UK, USA, Russia, Sweden". Since the
number of countries will vary, I need to know how to read the number of
records and display the results in 1 field. Any ideas?
 
F

fredg

I have a report that requires a summary of the country of manufacture of the
items contained therein. Sometimes I have only 1 country and it works fine.
When I have multiple countries, I need to take the results and put them in 1
field so it appears on the report like: "UK, USA, Russia, Sweden". Since the
number of countries will vary, I need to know how to read the number of
records and display the results in 1 field. Any ideas?

The following will work.
Place [ControlName] in the Report Footer.
Set it's CanGrow property to Yes.
Also set the Report Footer CanGrow to Yes.

Also in the Report Footer, add an unbound text control.
Set it's control source to:
=Count("*")
Name this control "RecCount"
You can make this control not visible.

Code the Format Event of the section of the report that shows the
[CountryName] field, i.e. Detail Format event:

If InStr(Nz([ControlName], ""), [CountryName]) = 0 Then
[ControlName] = [ControlName] & [CountryName] & ", "
End If
===============
Then in the Report Footer Print event:
[ControlName] = "There were " & [RecCount] & " records."& vbNewLine &
[ControlName]

The control will show the total number of records, with just one
listing of a country.

Change the [CountryName] field name to whatever your actual field name
is.

The print out will look like this:
There were 25 records.
Brazil, France, Sweden, etc.,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top