A unique composite index is just a unique index made up of more than one
field. Create a new table with the following fields based on your existing
data structure:
[PatientID]
[Claimnum]
[AllResults] - Memo
Save the table and create an index in design mode (button at the top with a
lightning bolt) called PatClaim.
Select the two fields [PatientID] and [Claimnum] and change the Unique
property to Yes. You can probably delete any indexes that Access
automatically made. This is your temporary table.
Create a query to append [PatientID] and [Claimnum] and execute it. Do this
by making a select query (for [PatientID] and [Claimnum]) and changing the
query type to Append (append to your temporary table). You can save this
query so that you can call it in code using DoCmd.OpenQuery or use an SQL
string to duplicate its function. Because of the unique property of the
index, you will never have the same [PatientID] and [Claimnum] combination
more than once.
Next, create an update query. Create a select query and change the query
type to Update. Another row will appear in the results pane called Update To.
Add your temporary table and your data source. Join [PatientID] and
[Claimnum] and update the [AllResults] field as such:
[AllResults] = [AllResults] & IIF(IsNull([AllResults]),"",", ") &
[FieldFromSource]
When you run this query, it will process all of the records in your data
souce one by one and add them to the [AllResults] field. The only drawback
to this is that a temporary table is created and must be erased every time.
However, your task is accomplished in essentially three queries and the
temporary table:
1) Delete query - remove all records from temporary table.
2) Append query - add all [PatientID] and [Claimnum] data.
3) Update query - concatenate all data into an existing field.
There are lots of places to learn about database design, indexes, queries,
etc. I'm sorry but I don't know any of them off the top of my head. I'm
sure a lot of other people in these forums can point you in the right
direction. HTH.
Thanks. Could you provide a little more information on this solution so I
can research how to set up the code? Is there a site you would recommend
[quoted text clipped - 6 lines]