OVH Cloud OVH Cloud

ecriture dans une colonne

1 réponse
Avatar
arkangel
Bonsoir,
J'ai ce bout de code suivant
Dim Cnn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim Strsql As String
Set Cnn = CurrentProject.Connection
Strsql = "SELECT *"
Strsql = Strsql & " FROM Client "
Strsql = Strsql & " WHERE (((Client.Statut)=0));"
Rs.Open Strsql, Cnn, adOpenDynamic, adLockOptimistic
' Affiche l'état des connexions.
MsgBox "ouverture de la base de données: " & GetState(Cnn.State)
If Rs.EOF Then GoTo Exit_Sub
With W_App
.Visible = True
Do Until Rs.EOF
.Documents.Open ("d:\doc2.doc")
.ActiveDocument.Bookmarks("Titre").Select
.Selection.InsertAfter Rs.Fields("Titre")
.ActiveDocument.Bookmarks("nom").Select
.Selection.InsertAfter Rs.Fields("nom")
.ActiveDocument.Bookmarks("Prénom").Select
.Selection.InsertAfter Rs.Fields("Prénom")
'.ActiveDocument.Bookmarks("postal").Select
'.Selection.InsertAfter Rs.Fields("client_codepostal")
'.ActiveDocument.Bookmarks("adresse").Select
'.Selection.InsertAfter Rs.Fields("client_adresse")
' .ActiveDocument.PrintOut False
'.ActiveDocument.Close wdDoNotSaveChanges
With txtStatut
.Locked = False
.Value = 1
.Locked = True
End With
Rs.MoveNext
'DoEvents
Loop
End With
Le problème est que le champs txtstatut passe bien à 1 la 1ere fois
mais pas la 2ème
Si j'ai deux enregistrements le 1er passe bien à 1 mais pas le 2ème
Si quelqu'un à une idée.
Txtstatut est un numeric dans ma base
Merci

--
Ceci est une signature automatique de MesNews.
Site : http://mesnews.no-ip.com

1 réponse

Avatar
Daniel Carollo
Bonjour Vincent!

Avec le code que vous avez joint, txtStatut est une variable locale, pas un
champ du recordset. Il est traite de facon differente dans la boucle de
code, pourquoi?

J'espere que ca vous met sur la piste...

--
Daniel :-)

Computing Technologies International - www.computing-tech.com - We
provide solutions...

"arkangel" wrote in message
news:
Bonsoir,
J'ai ce bout de code suivant
Dim Cnn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim Strsql As String
Set Cnn = CurrentProject.Connection
Strsql = "SELECT *"
Strsql = Strsql & " FROM Client "
Strsql = Strsql & " WHERE (((Client.Statut)=0));"
Rs.Open Strsql, Cnn, adOpenDynamic, adLockOptimistic
' Affiche l'état des connexions.
MsgBox "ouverture de la base de données: " & GetState(Cnn.State)
If Rs.EOF Then GoTo Exit_Sub
With W_App
.Visible = True
Do Until Rs.EOF
.Documents.Open ("d:doc2.doc")
.ActiveDocument.Bookmarks("Titre").Select
.Selection.InsertAfter Rs.Fields("Titre")
.ActiveDocument.Bookmarks("nom").Select
.Selection.InsertAfter Rs.Fields("nom")
.ActiveDocument.Bookmarks("Prénom").Select
.Selection.InsertAfter Rs.Fields("Prénom")
'.ActiveDocument.Bookmarks("postal").Select
'.Selection.InsertAfter Rs.Fields("client_codepostal")
'.ActiveDocument.Bookmarks("adresse").Select
'.Selection.InsertAfter Rs.Fields("client_adresse")
' .ActiveDocument.PrintOut False
'.ActiveDocument.Close wdDoNotSaveChanges
With txtStatut
.Locked = False
.Value = 1
.Locked = True
End With
Rs.MoveNext
'DoEvents
Loop
End With
Le problème est que le champs txtstatut passe bien à 1 la 1ere fois
mais pas la 2ème
Si j'ai deux enregistrements le 1er passe bien à 1 mais pas le 2ème
Si quelqu'un à une idée.
Txtstatut est un numeric dans ma base
Merci

--
Ceci est une signature automatique de MesNews.
Site : http://mesnews.no-ip.com