468,539 Members | 1,814 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,539 developers. It's quick & easy.

Combine multi-value field in Report

I have two tables

The first, MainTBL, has the following fields:

ID [Primary Key]
DefFIRST [text field]
DefMI [Text field]
DefLAST [Text field]
DefSUF [Text field]
DefDOB [Date/Time field]
Charge [Number - lookup field]
and several other fields.

The second table, ChargesTBL has the following fields:

ChargeID [Primary Key]
ID [number - linked to MainTBL]
Charge [Text]

The Charge field in ChargesTBL can hold many different values for each person in the MainTBL.

I would like to create a report that is grouped by DefLast, and lists all of the values of the charge field in a text box, separated by a comma.

The reports I've currently created list each charge on a separate line.

Thanks in advance.
May 5 '15 #1
8 3830
zmbd
5,400 Expert Mod 4TB
lineone
Unless you are creating a webapp/sharepoint site I highly advise that you change your lookup field
[Charge [Number - lookup field]]
to a plain numeric and here is why:
The Evils of Lookup Fields in Tables

You can and should normally create your lookup fields within either a query or form.

Set up your table relationships via the Database tools.
(if in ACC2013 you can get at this from the table design view too)

As for what you are asking, I assume you mean something like what is shown in the post >here< for the example report.

Once you have your relationships setup properly, you can build a query that pulls the main table and related table(s), verify the relationships are correct, and return the fields of interest. You might open the database referenced in the above post and follow the instructions there to see how the report is constructed.

Let us know how you progress...
May 5 '15 #2
ZMBD,

Thanks much for your prompt reply. I'm still a bit stumped (I'm new at this), and believe that I may not have describe how I actually setup the tables and relationships. I've included the database in the hope you can guide me through my inexperience. I'm using Access 2013 but saved this in the 2003 version to make it more accessible. Again, thanks for all you've done.
Attached Files
File Type: zip Access2003-DRC2015.zip (930.8 KB, 79 views)
May 6 '15 #3
zmbd
5,400 Expert Mod 4TB
I'll send you a copy of my "tool kit" via PM

You may also find the following to be useful if you are having trouble creating your relationships:
How to define relationships between tables in an Access database

This describes a lookup field: Create a lookup field which I personally avoid as noted in my first reply. :)
May 6 '15 #4
Thanks, ZMBD.

I was wrong about my Charge field being a lookup; it is indeed a numeric field. It seems I'm merely having a problem creating a report that will put all of the values from ChargesTBL.Charge into a text box, with each charge separated by a comma rather than a new line. I didn't explain myself very well. A JPG is attached showing my relationship between the two tables.

Thanks, again

My original post should have read:

I have two tables

The first, MainTBL, has the following fields:

ID [Primary Key]
DefFIRST [text field]
DefMI [Text field]
DefLAST [Text field]
DefSUF [Text field]
DefDOB [Date/Time field]
Charge [Number]
and several other fields.

The second table, ChargesTBL has the following fields:

ChargeID [Primary Key]
ID [number - linked to MainTBL ID Primary Key]
Charge [Text]

The Charge field in ChargesTBL can hold many different values for each person in the MainTBL.

I would like to create a report that is grouped by DefLast, and lists all of the values of the charge field in a text box, separated by a comma.

The reports I've currently created list each charge on a separate line.

Attached Images
File Type: jpg Relationship.jpg (28.6 KB, 1296 views)
May 6 '15 #5
zmbd
5,400 Expert Mod 4TB
Ok, you'll need a tad of code.
Before I potentially lead down the wrong path, let me repeat things:

Currently you have something like:
Expand|Select|Wrap|Line Numbers
  1. Family PK - Family Name - - Retreat Name
  2. 1           Alpha           Annunciation
  3.                             Dummy Data Rulles
  4.  
  5. 2           Beta            Annunciation
  6.                             Getting to know your spouse
  7. ...
  8. 15          November        Nativity
  9.                             (etc...)                             
Instead you would like:
Expand|Select|Wrap|Line Numbers
  1. Family PK - Family Name - - Retreat Name
  2. 1           Alpha           Annunciation, Dummy Data Rulles
  3.  
  4. 2           Beta            Annunciation, Getting to know your spouse, 3rd, 4th, etc...
  5. ...
  6. 15          November        Nativity, 2nd, 3rd, 4th, etc...
  7. (etc...)
May 6 '15 #6
Yes, ZMDB, I couldn't have illustrated it better. Thanks.
May 6 '15 #7
zmbd
5,400 Expert Mod 4TB
Ahh... I have a function built for that... but it is on the toasted-pc... arrrgghh/

If I can find my backup I'll post


The concept is to build a custom function.
It opens a record set that loops thru the related records based on the current record and builds the string then returns it.

I am pretty sure we've covered this exact thing about a year or so ago...
May 6 '15 #8
NeoPa
32,101 Expert Mod 16PB
Combining Multiple Rows of one Field into One Result has an example of such a function.
May 7 '15 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by tina.boroff | last post: by
7 posts views Thread by BillCo | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.