Dim xMatricule As String,sChaine As String While Not rsttable.EOF if xMatricule=rsttable!matricule Then sChaine=<chaine à concaténer dans ce cas> Else sChaine=<chaine à concaténer dans ce cas> End If Print#1,sChaine rsttable.MoveNext If rsttable.BOF and rsttable.EOF Then Exit Do xMatricule=rsttable!matricule Wend
Dim xMatricule As String, xNom, As String, _ xPrenom As String, xService As String, xDiretion As String 'on se positionne sur le premier et on sauvegarde. rsttable.MoveFirst xMatricule=rsttable!matricule xNom=rsttable!nom xPrenom=rsttable!prenom xService= rsttable!service xDirection=rstable!direction 'on passe au suivant rsttable.MoveNext rsttable.MoveFirst While Not rsttable.EOF 'on teste if xMatricule=rsttable!matricule Then print#1, xMatricule & xNom & xPrenom & _ xService & xDirection & _ rsttable!service & rstable!direction Else print#, xMatricule & xNom & xPrenom & _ xService & xDirection End If 'On sauvegarde les champs courants avant de passer à l' enregistrement suivant. xMatricule=rsttable!matricule xNom=rsttable!nom xPrenom=rsttable!prenom xService= rsttable!service xDirection=rstable!direction 'on passe au suivant rsttable.MoveNext Wend
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question"je crois il faux introduire la fonction for."
Dim xMatricule As String, xNom, As String, _ xPrenom As String, xService As String, xDiretion As String With rsttable 'on se positionne sur le premier . .MoveFirst While Not .EOF 'on teste if xMatricule=!matricule Then print#1, xMatricule & xNom & xPrenom & _ xService & xDirection & _ !service & !direction Else print#, !matricule & !nom & !prenom & _ !service & !direction End If 'On sauvegarde les champs courants avant de passer à l' enregistrement suivant. xMatricule=!matricule xNom=!nom xPrenom=!prenom xService=!service xDirection=!direction 'on passe au suivant .MoveNext Wend End With
Dim xMatricule As String, sChaine As String With rsttable 'on se positionne sur le premier . .MoveFirst While Not .EOF xMatricule=!matricule sChaine =!matricule & !nom & !prenom Do While Not .EOF And xMatricule=!matricule sChaine =sChaine & !service & !direction .MoveNext 'très important If .EOF Then Exit Do Loop print#, sChaine Wend End With
Set rsttable = New ADODB.Recordset rsttable.Open "SELECT * FROM cariére" & _ " ORDER BY matricule;",MaConn, , ,adCmdTable
je veux exporter le contenu dans un fichier
sous format
matricule(10char)&nom(40char)&prénom(40char)&service(2 char)& direction (4char)
mais avant de retourner à la ligne je vérifié la ligne suivante [b]si le même matricule j'ajoute:
& service & direction /bau premier ligne et c'est ça exactement mon pb