1 pièce(s) jointe(s)
Concatenation via code VBA
bonjour a tous ,
a la recherche d'une solution pour ma requete ,je me permet d 'exprimer mon besoin . j'ai le tableau ci-dessous :
Pièce jointe 651436
mon souhait est de concatonner la colonne : Num_compte , donc chaque NTiers dois avoir une seule ligne avec les 3 numero de compte .
quelqu'un m'avait donner ce code , helas j'ai pu alles plus loin sur cette requete :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
Function ConcatForQuery(strRegroup As String, fldRegroup As String, _
strConcat As String, strTable As String, _
Optional strSep As String = " / ") As String
'** Regroupement de donnée sur le champ fldRegroup
'** et concaténation sur le champ strConcat
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strResult As String
Dim strRst As String
Set db = CurrentDb()
strRst = "Select * From [" & strTable & "] " _
& "Where [" & strRegroup & "] = """ & fldRegroup & """;"
Set rst = db.OpenRecordset(strRst, dbOpenDynaset)
With rst
If Not .BOF Then
.MoveFirst
Do Until .EOF
If strResult = "" Then
strResult = .Fields(strConcat)
Else
strResult = strResult & strSep & .Fields(strConcat)
End If
.MoveNext
Loop
End If
End With
rst.Close: Set rst = Nothing
db.Close: Set db = Nothing
ConcatForQuery = strResult
End Function |