Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenating with Do…Loop 1

Status
Not open for further replies.

jaaret

Instructor
Jun 19, 2002
171
I am not very familiar with Do...Loop. Can it be used to concatonate multiple records into one long string? For example, if I have a table that lists meeting attendees:

Judy
Dennis
Patrick

Can Do...Loop concatonate the names into one field with the names separated by commas, such as:

Judy, Dennis, Patrick

It seems do-able. I'm just not sure how.

Thanks in advance,
Jaaret
 
There is a generic concatenate function in the FAQs (I think the Querys forum) and sample usage in a download at
Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
How are ya jaaret . . .

Here's an example of a function using the recordset of a form to return the final string:
Code:
[blue]Public Function Build() As String
   Dim rst As DAO.Recordset, Pack As String
   
   Set rst = Me.RecordsetClone
   
   If Not rst.BOF Then
      Do
         If Pack <> "" Then
            Pack = Pack & "," & rst![purple][b]Attendees[/b][/purple]
         Else
            Pack = rst!Attendees
         End If
         
         rst.MoveNext
      Loop Until rst.EOF
   End If
   
   Build = Pack

End Function[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
While RecordsetClone might work in a form, it doesn't in any version of Access that I have installed.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Howdy dhookom! . . .

I'm believing the only way to do this directly is thru a form! . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top