Boucle + Recordset

alias666 Messages postés 308 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 23 mars 2010 - 8 déc. 2004 à 10:16
alias666 Messages postés 308 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 23 mars 2010 - 9 déc. 2004 à 09:45
Salut tout le monde :)
J'ai un tit problème en fiat qu'est bizzare j'ai une table "TableImport" dans laquelle est stockées toutes mes valeurs. Dans une autre "DétailProfil" j'ai les valeurs d'un profil qu'il aura sélectionner dans un treeview auparavant. Le problème est que quand je veux stocker mes données dans une table annexe "Impression" qui servira par la suite à etre imprimé sous Crystal Report. Et donc dans la table "TableImport" il y de temps en temps le champs "Page" et le champ "Item" qui sont égaux dans ce cas là les enregistrements de ce type sont à la suite. Et donc il ne passe pas dedans je voudrai savoir pourquoi... Si ya besoin d'explication dites moi.

Db.Execute "DELETE * from Impression", dbOpenDynaset                        Set Rst Db.OpenRecordset("Select * From DetailProfil Where Numprofil" & cboProfil.ItemData(cboProfil.ListIndex), dbOpenSnapshot)
                        While Not Rst.EOF                                Set Rst2 Db.OpenRecordset("Select * From TableImport Where TableImport.Libellé""" & Trim(cboPc.List(cboPc.ListIndex)) & """ And TableImport.Page=""" & Rst!Page & """ And TableImport.Item =""" & Rst!Item & """ and TableImport.Group=""" & Rst!Group & """", dbOpenDynaset)
                                If Rst.EOF Then
                                        While Not Rst2.EOF
                                                Set Rst3 = Db.OpenRecordset("select * from Impression", dbOpenDynaset)
                                                Rst3.AddNew
                                                Rst3!NumProfil = cboProfil.ItemData(cboProfil.ListIndex)
                                                Rst3!Libellé = Trim(cboPc.List(cboPc.ListIndex))
                                                Rst3!Page = Rst!Page
                                                Rst3!device = Rst2!device
                                                Rst3!Group = Rst!Group
                                                Rst3!Item = Rst!Item
                                                Rst3!Value = Rst2!Value
                                                Rst3.MoveNext
                                                Rst3.Update
                                                Rst3.Close
                                        Wend
                                Else                                        Set Rst4 Db.OpenRecordset("Select * From TableImport Where TableImport.Libellé""" & Trim(cboPc.List(cboPc.ListIndex)) & """ And TableImport.Page=""" & Rst!Page & """ And TableImport.Item=""" & Rst!Group & """", dbOpenDynaset)
                                        If Not Rst4.EOF Then
                                                Set Rst5 = Db.OpenRecordset("Select * from Impression", dbOpenDynaset)
                                                Rst5.AddNew
                                                Rst5!NumProfil = cboProfil.ItemData(cboProfil.ListIndex)
                                                Rst5!Libellé = Trim(cboPc.List(cboPc.ListIndex))
                                                Rst5!Page = Rst!Page
                                                Rst5!device = Rst4!device
                                                Rst5!Group = Rst!Group
                                                Rst5!Item = Rst!Item
                                                Rst5!Value = Rst4!Value
                                                Rst5.Update
                                                Rst5.Close
                                        Else
                                                Set Rst5 = Db.OpenRecordset("Select * from Impression", dbOpenDynaset)
                                                Rst5.AddNew
                                                Rst5!NumProfil = cboProfil.ItemData(cboProfil.ListIndex)
                                                Rst5!Libellé = Trim(cboPc.List(cboPc.ListIndex))
                                                Rst5!Page = Rst!Page
                                                Rst5!device = IIf(IsNull(Rst4!device), "", Rst2!device)
                                                Rst5!Group = Rst!Group
                                                Rst5!Item = Rst!Item
                                                Rst5!Value = IIf(IsNull(Rst4!Value), "", Rst2!Value)
                                                Rst5.Update
                                                Rst5.Close
                                        End If
                                End If


Voici mon code
_______________________
<<<< :-: 4L!@$ :-: >>>>

4 réponses

alias666 Messages postés 308 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 23 mars 2010
8 déc. 2004 à 10:40
PS : Je précise qu'il ne passe pas dans la boucle principale.

[code]
Db.Execute "DELETE * from Impression", dbOpenDynasetSet Rst Db.OpenRecordset("Select * From DetailProfil Where Numprofil" & cboProfil.ItemData(cboProfil.ListIndex), dbOpenSnapshot)
While Not Rst.EOF Set Rst2 Db.OpenRecordset("Select * From TableImport Where TableImport.Libellé""" & Trim(cboPc.List(cboPc.ListIndex)) & """ And TableImport.Page=""" & Rst!Page & """ And TableImport.Item =""" & Rst!Item & """ and TableImport.Group=""" & Rst!Group & """", dbOpenDynaset)
If Rst.EOF Then
While Not Rst2.EOF
Set Rst3 = Db.OpenRecordset("select * from Impression", dbOpenDynaset)
Rst3.AddNew
Rst3!NumProfil = cboProfil.ItemData(cboProfil.ListIndex)
Rst3!Libellé = Trim(cboPc.List(cboPc.ListIndex))
Rst3!Page = Rst!Page
Rst3!device = Rst2!device
Rst3!Group = Rst!Group
Rst3!Item = Rst!Item
Rst3!Value = Rst2!Value
Rst3.MoveNext
Rst3.Update
Rst3.Close
Wend
ElseSet Rst4 Db.OpenRecordset("Select * From TableImport Where TableImport.Libellé""" & Trim(cboPc.List(cboPc.ListIndex)) & """ And TableImport.Page=""" & Rst!Page & """ And TableImport.Item=""" & Rst!Group & """", dbOpenDynaset)
If Not Rst4.EOF Then
Set Rst5 = Db.OpenRecordset("Select * from Impression", dbOpenDynaset)
Rst5.AddNew
Rst5!NumProfil = cboProfil.ItemData(cboProfil.ListIndex)
Rst5!Libellé = Trim(cboPc.List(cboPc.ListIndex))
Rst5!Page = Rst!Page
Rst5!device = Rst4!device
Rst5!Group = Rst!Group
Rst5!Item = Rst!Item
Rst5!Value = Rst4!Value
Rst5.Update
Rst5.Close
Else
Set Rst5 = Db.OpenRecordset("Select * from Impression", dbOpenDynaset)
Rst5.AddNew
Rst5!NumProfil = cboProfil.ItemData(cboProfil.ListIndex)
Rst5!Libellé = Trim(cboPc.List(cboPc.ListIndex))
Rst5!Page = Rst!Page
Rst5!device = IIf(IsNull(Rst4!device), "", Rst2!device)
Rst5!Group = Rst!Group
Rst5!Item = Rst!Item
Rst5!Value = IIf(IsNull(Rst4!Value), "", Rst2!Value)
Rst5.Update
Rst5.Close
End If
End If
Rst2.Close
If pbChargement.Value = pbChargement.Max Then
Exit Sub
Else
pbChargement.Value = pbChargement.Value + 1
End If
Rst.MoveNext
Wend

_______________________
<<<< :-: 4L!@$ :-: >>>>
0
alias666 Messages postés 308 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 23 mars 2010
8 déc. 2004 à 10:40
PS : Je précise qu'il ne passe pas dans la boucle principale.

Db.Execute "DELETE * from Impression", dbOpenDynasetSet Rst Db.OpenRecordset("Select * From DetailProfil Where Numprofil" & cboProfil.ItemData(cboProfil.ListIndex), dbOpenSnapshot)
 While Not Rst.EOF Set Rst2  Db.OpenRecordset("Select * From TableImport Where TableImport.Libellé""" & Trim(cboPc.List(cboPc.ListIndex)) & """ And TableImport.Page=""" & Rst!Page & """ And TableImport.Item =""" & Rst!Item & """ and TableImport.Group=""" & Rst!Group & """", dbOpenDynaset)
If Rst.EOF Then
While Not Rst2.EOF
Set Rst3 = Db.OpenRecordset("select * from Impression", dbOpenDynaset)
Rst3.AddNew
Rst3!NumProfil = cboProfil.ItemData(cboProfil.ListIndex)
Rst3!Libellé = Trim(cboPc.List(cboPc.ListIndex))
Rst3!Page = Rst!Page
Rst3!device = Rst2!device
Rst3!Group = Rst!Group
Rst3!Item = Rst!Item
Rst3!Value = Rst2!Value
Rst3.MoveNext
Rst3.Update
Rst3.Close
Wend
ElseSet Rst4 Db.OpenRecordset("Select * From TableImport Where TableImport.Libellé""" & Trim(cboPc.List(cboPc.ListIndex)) & """ And TableImport.Page=""" & Rst!Page & """ And TableImport.Item=""" & Rst!Group & """", dbOpenDynaset)
If Not Rst4.EOF Then
Set Rst5 = Db.OpenRecordset("Select * from Impression", dbOpenDynaset)
Rst5.AddNew
Rst5!NumProfil = cboProfil.ItemData(cboProfil.ListIndex)
Rst5!Libellé = Trim(cboPc.List(cboPc.ListIndex))
Rst5!Page = Rst!Page
Rst5!device = Rst4!device
Rst5!Group = Rst!Group
Rst5!Item = Rst!Item
Rst5!Value = Rst4!Value
Rst5.Update
Rst5.Close
Else
Set Rst5 = Db.OpenRecordset("Select * from Impression", dbOpenDynaset)
Rst5.AddNew
Rst5!NumProfil = cboProfil.ItemData(cboProfil.ListIndex)
Rst5!Libellé = Trim(cboPc.List(cboPc.ListIndex))
Rst5!Page = Rst!Page
Rst5!device = IIf(IsNull(Rst4!device), "", Rst2!device)
Rst5!Group = Rst!Group
Rst5!Item = Rst!Item
Rst5!Value = IIf(IsNull(Rst4!Value), "", Rst2!Value)
Rst5.Update
Rst5.Close
End If
End If
                                Rst2.Close
                                If pbChargement.Value = pbChargement.Max Then
                                        Exit Sub
                                Else
                                        pbChargement.Value = pbChargement.Value + 1
                                End If
                                Rst.MoveNext
                       Wend

_______________________
<<<< :-: 4L!@$ :-: >>>>
0
Cramfr Messages postés 160 Date d'inscription mercredi 24 novembre 2004 Statut Membre Dernière intervention 8 juillet 2008
8 déc. 2004 à 16:53
Ben tu es passé en déboggage ??
ou tu mets un msgbox pour connaitre la valeur de :
[code]
cboProfil.ItemData(cboProfil.ListIndex)
[code]
Cramsoturf le VBien en quête de nouveau programme :big)
0
alias666 Messages postés 308 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 23 mars 2010
9 déc. 2004 à 09:45
Il me renvoie bien la valeur du pc traité en ce moment je comprends pas...
_______________________
<<<< :-: 4L!@$ :-: >>>>
0
Rejoignez-nous