Hi I have been using Duanes code to concatenate names from at the same address e.g Jack,James, Jill
I would like to do Jack, James & Jill
Any Ideas on how to add the & before the last record?
Cheers
Ben
Function Concatenate(pstrSQL As String, _
Optional pstrDelim As String = ",") _
As String
'Created by Duane Hookom, 2003
Dim endstring As String
Dim rs As New ADODB.Recordset
rs.Open pstrSQL, CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic
Dim strConcat As String 'build return string
Dim intCount As Integer
intCount = 0
With rs
If Not .EOF Then
.MoveFirst
Do While Not .EOF
' intCount = intCount + 1
strConcat = strConcat & _
"" & .Fields(0) & pstrDelim
.MoveNext
Loop
End If
.Close
End With
Set rs = Nothing
'====== uncomment next line for DAO ========
'Set db = Nothing
If Len(strConcat) > 0 Then
strConcat = Left(strConcat, _
Len(strConcat) - Len(pstrDelim))
End If
Concatenate = strConcat
End Function
I would like to do Jack, James & Jill
Any Ideas on how to add the & before the last record?
Cheers
Ben
Function Concatenate(pstrSQL As String, _
Optional pstrDelim As String = ",") _
As String
'Created by Duane Hookom, 2003
Dim endstring As String
Dim rs As New ADODB.Recordset
rs.Open pstrSQL, CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic
Dim strConcat As String 'build return string
Dim intCount As Integer
intCount = 0
With rs
If Not .EOF Then
.MoveFirst
Do While Not .EOF
' intCount = intCount + 1
strConcat = strConcat & _
"" & .Fields(0) & pstrDelim
.MoveNext
Loop
End If
.Close
End With
Set rs = Nothing
'====== uncomment next line for DAO ========
'Set db = Nothing
If Len(strConcat) > 0 Then
strConcat = Left(strConcat, _
Len(strConcat) - Len(pstrDelim))
End If
Concatenate = strConcat
End Function