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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combine the same field in multiple records into a string 1

Status
Not open for further replies.

Senjen

Programmer
Jul 14, 2000
23
US
i want to combine the "name" field from all records with the same "child id" into a string to insert into a text field. the fields are located in the same qry result "XQryTal". Any help would be greatly appreciated. i have checked knowledebase, help, and threads for a like question for 2 days.
 
You'll have to build the recordset and then iterate through it building your string. Depending on your version of Access the following may have to be modified slightly. I haven't checked for syntax(no guarantees there) but it should give you the picutre.

...
Dim dbs As Database
Dim rst As Recordset
Dim strSQL As String
Dim strString as String

Set dbs = CurrentDB
strSQL = "SELECT * FROM XQryTal WHERE [name] = 'ChildID'"
Set rst = dbs.OpenRecordSet(strSQL)

rst.MoveFirst

While Not EOF
With rst
strString = strString & " " & .name
.MoveNext
End With
Wend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top