Aide V.B.A.

Résolu
elpolo76 Messages postés 42 Date d'inscription   Statut Membre Dernière intervention   -  
elpolo76 Messages postés 42 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

Bonjourj'essai d'executer une requete sur VBA et ca ne marche po !! kelkun pe til ma'idez svp!!!!

c'est un pe lon g mais !!!!!j'espere bien trouvé de l'aide!!

'Declatarion des variables

Dim MyWS As Database, MyDB As Database, MyTd As Recordset, Monform As Form
Dim MyTA As Recordset, BILMENSTOTAUXCUMUL As Recordset, BILMENS_1 As Recordset, BILMENS_2 As Recordset, BILMENS_3 As Recordset
Dim SSTCOD As String, SSTRNOM As String, PER As Integer, SSTANN As String, SSTMOI As String, CAFR As String
Dim SommeDeQPIELIV As Integer, SommeDeQtencfe As Integer, SommeDeCAFR As Integer, SommeDeQtencfeCrit As Integer, SommeDeQtencfeNCrit As Integer
Dim SommeDeQtelivNCrit As Integer, SommeDeQtelivCrit As Integer, SommeDeCnqCrit As Integer, SommeDeCnqNCrit As Integer
Dim Qpieliv As Integer
Dim Nbreliv As Integer
Dim SommeDeNBRELIV As Integer
Dim Nbretot As Integer, Nsst As Integer, Somme1 As Integer, Som2 As Integer
Dim Pourvib As String, PCA As String
Dim Critique As Integer
Dim Cnq As String, crit1 As Integer, crit2 As Integer
Dim SNOTD As String, NOTC As String, NOTD As String
Dim Note1 As Integer, Note2 As Integer, Note3 As Integer
Dim ASQL As String
Dim requete As String
Dim datdeb As String, Datfin As String
Dim AQSSTONYX As Recordset
Dim Poursst As String, Pvib As String, Psst As String
Dim Vibcrit As Integer, VibNcrit As Integer, AnoOcrit As Integer, AnoONcrit As Integer


' Gestion d'erreur

'On Error GoTo TRAITER_ERRSY


'Procedure de consolidation

Set MyDB = CurrentDb()

'Creation de la table Bilmens
Set MyTd = MyDB.OpenRecordset("BILMENSCUMUL")

'Mize a zéro de la table

ASQL = "Delete * From BILMENSCUMUL;"
DoCmd.RunSQL ASQL

Set Monform = Forms![Bilan mensuel]





'Lecture de la table bilmens

requete = " SELECT DISTINCTROW BILMENSTOTAUXCUMUL.SSTCOD,BILMENSTOTAUXCUMUL.SSTRNOM, BILMENSTOTAUXCUMUL.SommeDeNBRELIV AS Nbreliv,[BILMENS_1].Nbretot,BILMENSTOTAUXCUMUL.SommeDeQPIELIV AS Qpieliv,[BILMEN_1].SommeDeQtencfe AS Somme1,BILMENSTOTAUXCUMUL.SommeDeCAFR AS CAFR,[BILMENS_1].SommeDeQtencfeCrit,[BILMENS_1].SommeDeQtencfeNCrit,[BILMENS_1].SommeDeQtelivNCrit,[BILMENS_1].SommeDeQtelivCrit,[BILMENS_1].SommeDeCnqCrit,[BILMENS_1].SommeDeCnqNCrit"
requete = requete & " FROM ((BILMENSTOTAUXCUMUL LEFT JOIN [BILMENS_1] ON BILMENSTOTAUXCUMUL.SSTCOD = [BILMENS_1].Codss) LEFT JOIN [BILMENS_2] ON BILMENSTOTAUXCUMUL.SSTCOD = [BILMENS_2].Codss) LEFT JOIN [BILMENS_3] ON BILMENSTOTAUXCUMUL.SSTCOD = [BILMENS_3].Codss"
requete = requete & " GROUP BY BILMENSTOTAUXCUMUL.SSTCOD,BILMENSTOTAUXCUMUL.SSTRNOM,BILMENSTOTAUXCUMUL.SommeDeNBRELIV,[BILMENS_1].Nbretot,BILMENSTOTAUXCUMUL.SommeDeQPIELIV,[BILMENS_1].SommeDeQtencfe,BILMENSTOTAUXCUMUL.SommeDeCAFR,BILMENS_1.SommeDeQtencfeCrit,[BILMENS_1].SommeDeQtencfeNCrit, [BILMENS_1].SommeDeQtelivNCrit, [BILMENS_1].SommeDeQtelivCrit,[BILMENS_1].SommeDeCnqCrit,[BILMENS_1].SommeDeCnqNCrit;"

Debug.Print requete

Set MyTA = MyDB.OpenRecordset(requete)
MErci!!!!

3 réponses

blux Messages postés 27121 Date d'inscription   Statut Modérateur Dernière intervention   3 359
 
Salut,

si tu nous disais pourquoi "ca ne marche po" ?
0
elpolo76 Messages postés 42 Date d'inscription   Statut Membre Dernière intervention   2
 
J sait po prkoi ca marche po !!comme eureur ca me met 1 paramettre atendu !!!o nivo de la requete !!mais apres je sait po si ma syntaxe est bonne ou po !!jai tt essayer§!:
0
blux Messages postés 27121 Date d'inscription   Statut Modérateur Dernière intervention   3 359 > elpolo76 Messages postés 42 Date d'inscription   Statut Membre Dernière intervention  
 
Merci d'éviter le SMS, je suppose que ton clavier possède une centaine de touches...

comme eureur ca me met 1 paramettre atendu
A quelle ligne ? parce que "o nivo de la requete", c'est pas assez précis (constitution, exécution ?)
0
elpolo76 Messages postés 42 Date d'inscription   Statut Membre Dernière intervention   2 > blux Messages postés 27121 Date d'inscription   Statut Modérateur Dernière intervention  
 
Désolé pour le sms !!!


Je m'explique .
Quant je compile, arrivé au niveau de Set MyTA = MyDB.OpenRecordset(requete), ca s'arrette et ca maffiche !!!
erreur d'execution "3061" TROP peu de parametre !!!!1 attendu!!!!


Je profite pour vous montrer en meme temps une autre requete :


requete = "SELECT DISTINCTROW AQSSTONYX.SSTCOD,[SSTANN] & [SSTMOI] AS PER, AQSSTONYX.SSTANN, AQSSTONYX.SSTMOI, AQSSTONYX.QPIELIV, AQSSTONYX.NBRELIV, AQSSTONYX.CAFR FROM AQSSTONYX"
requete = requete & " WHERE ([SSTANN] & [SSTMOI]) <= " Mid( #" & arrive & " #, 7, 4) & Mid( # " & arrive & "# ,4 , 2)" AND ([SSTANN] & [SSTMOI])>= " Mid( # " & depart & " # , 7, 4) & Mid( # " & depart & " #, 4, 2)" ;"


Debug.Print requete

Set MyTA = MyDB.OpenRecordset(requete)
Le probleme sur cette derniere ce situe au niveau de WHERE AND!!!je veut au fait que mon( [SSTANN] & [SSTMOI]) soit comprise entre les 2 mid !!!cela compile mais a la verification je remarque qu'elle m'ajoute dautre valeur legerement inferieure!!! je veut au fait savoir si cette syntaxe est la bonne .
Je me reexplique encore !!jai 3 champ: SSTANN(anne de soutraitant) SSTMOI et PER=( [SSTANN] & [SSTMOI])

arrive et depart sont des valeur que je recupere de mon formulaire et qui sont sous la forme xx/xx/xxxx
je veut au fait selectionner les PER comprise en tree arrive et depart en concatenant juste l'annee et le mois!!
merci
0
blux Messages postés 27121 Date d'inscription   Statut Modérateur Dernière intervention   3 359 > elpolo76 Messages postés 42 Date d'inscription   Statut Membre Dernière intervention  
 
C'est que te requête est mal faite. Il faudrait la recopier et la lancer en direct, tu verrais surement le problème...

Pour le reste, c'est pas un bon plan de comparer des dates en format string...
0
elpolo76 Messages postés 42 Date d'inscription   Statut Membre Dernière intervention   2 > blux Messages postés 27121 Date d'inscription   Statut Modérateur Dernière intervention  
 
comment on lance une requete en direct sur VBA?
0
elpolo76 Messages postés 42 Date d'inscription   Statut Membre Dernière intervention   2
 
Merci beaucoup je vais l'eesayer !!!
je vien de voir aussi que je pe remplacer le DoCmd.RunSQL ASQL!!!par CurrentDb.Execute ASQL!!!
A ton avis (parcekque ton avis est meilleur ) elle marche aussi le CurrentDb.Execute ASQL??
Merci
0
blux Messages postés 27121 Date d'inscription   Statut Modérateur Dernière intervention   3 359
 
ben voui, c'est ce que j'ai écrit dans mon message précédent...
0
elpolo76 Messages postés 42 Date d'inscription   Statut Membre Dernière intervention   2 > blux Messages postés 27121 Date d'inscription   Statut Modérateur Dernière intervention  
 
Ben !!ca marche !!Encore merci !!et a une prochaine pe etre!!Bonne journnée!!!!
0
elpolo76 Messages postés 42 Date d'inscription   Statut Membre Dernière intervention   2
 
probleme resolu
0