Bonjour,
J'ai un peu avancé en feuilletant les divers sites.
J'ai maintenant récupéré et aménagé une fonction
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
| Public Function ConcatForQuery(strRegroup As String, fldRegroup As String, strConcat As String, strTable As String, Optional strSep As String = "/") As String
Dim db As Database
Dim rst As Recordset
Dim strResult As String
Dim strsql As String
Set db = CurrentDb()
'Selectionne les memos du projet
strsql = "select * from [" & strTable & "]" _
& "where [" & strRegroup & "] = """ & fldRegroup & """;"
Set rst = CurrentDb.OpenRecordset(strsql, dbOpenDynaset)
'concatene les memos
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 |
Cette fonction je l'appelle de la façon suivante :
Me![SF_Concat].Form.RecordSource = "SELECT *, Concatforquery(" & CI_Asset & ",[CI_Asset]," & CI_Comments & ",tbl_temp_CapacityIncrements," - ") AS Resultat FROM tbl_temp_CapacityIncrements GROUP BY CI_Asset;"
J'ai un peu simplifié par rapport à ce que je recherche mais je me prends la tête avec la syntaxe des " des ' et des &, au mieux j'ai mon formulaire vide avec des #nom ou bien des erreurs de type, bref je patauge.
Merci de l'aide
Partager