IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBA Access Discussion :

[access]une Requete Marchant Sous Access Ne Marche Pas En Vba!


Sujet :

VBA Access

  1. #1
    Membre régulier Avatar de Dryss51
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 113
    Points : 91
    Points
    91
    Par défaut [access]une Requete Marchant Sous Access Ne Marche Pas En Vba!
    Bonjour,

    Dans un contexte d'archivage, j'ai réalisé des requètes de suppression.
    Ces requètes fonctionnent parfaitement dans access, j'ai donc récupéré le code sql que j'ai mis dans une variable chaine de caractère "SuppAction".
    J'execute ensuite cette variable grace à un docmd.runSql SuppAction. (Tout ceci est réaliser à la suite d'un click_bouton.)

    Et cela génère une erreur de syntaxe 3075 !!

    Voila un Bout du code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    SuppAction = "DELETE DISTINCTROW Action.*, [Commande Matériel Exxon].N°CommandeExxon" _
            & "FROM (Proposition INNER JOIN ([Action] INNER JOIN Générer ON Action.N°Action = Générer.N°Action) ON Proposition.N°propo = Générer.N°propo) INNER JOIN ([Commande Matériel Exxon] INNER JOIN ([Affaire SIE] INNER JOIN (Matériel INNER JOIN Posseder ON Matériel.[iD Matériel] = Posseder.[iD Matériel]) ON [Affaire SIE].N°AffaireSIE = Matériel.N°AffaireSIE) ON [Commande Matériel Exxon].N°CommandeExxon = [Affaire SIE].N°CommandeExxon) ON Proposition.N°propo = Posseder.N°propo" _
            & "WHERE ((([Commande Matériel Exxon].N°CommandeExxon)= "& N°Comm & "));"
     
    DoCmd.RunSQL SuppAction
    Si quelqu'un pourrait m'aider car la je bloque....

  2. #2
    Expert éminent sénior
    Avatar de Domi2
    Homme Profil pro
    Gestionnaire
    Inscrit en
    Juin 2006
    Messages
    7 194
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : Suisse

    Informations professionnelles :
    Activité : Gestionnaire
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Juin 2006
    Messages : 7 194
    Points : 16 044
    Points
    16 044
    Par défaut
    Bonjour,

    Essaie déjà comme ceci. J'ai mis un espace avant le " de fin de ligne.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    SuppAction = "DELETE DISTINCTROW Action.*, [Commande Matériel Exxon].N°CommandeExxon " & _
                 "FROM (Proposition INNER JOIN ([Action] INNER JOIN Générer ON Action.N°Action = Générer.N°Action) ON Proposition.N°propo = Générer.N°propo) INNER JOIN ([Commande Matériel Exxon] INNER JOIN ([Affaire SIE] INNER JOIN (Matériel INNER JOIN Posseder ON Matériel.[iD Matériel] = Posseder.[iD Matériel]) ON [Affaire SIE].N°AffaireSIE = Matériel.N°AffaireSIE) ON [Commande Matériel Exxon].N°CommandeExxon = [Affaire SIE].N°CommandeExxon) ON Proposition.N°propo = Posseder.N°propo " & _
                 "WHERE ((([Commande Matériel Exxon].N°CommandeExxon)= "& N°Comm & "));"
    Domi2

  3. #3
    Membre régulier Avatar de Dryss51
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 113
    Points : 91
    Points
    91
    Par défaut Attention au erreur bète
    Je n'efface pas ce post car il peut conduire certaine personne à débugger, j'ai cherché et recherché, cela faisait 2h que j'etais entrain de me triturer les méninges.

    Je Poste sur le forum, et je fais ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    SuppAction = "DELETE DISTINCTROW Action.*, [Commande Matériel Exxon].N°CommandeExxon" _
            & " FROM (Proposition INNER JOIN ([Action] INNER JOIN Générer ON Action.N°Action = Générer.N°Action) ON Proposition.N°propo = Générer.N°propo) INNER JOIN ([Commande Matériel Exxon] INNER JOIN ([Affaire SIE] INNER JOIN (Matériel INNER JOIN Posseder ON Matériel.[iD Matériel] = Posseder.[iD Matériel]) ON [Affaire SIE].N°AffaireSIE = Matériel.N°AffaireSIE) ON [Commande Matériel Exxon].N°CommandeExxon = [Affaire SIE].N°CommandeExxon) ON Proposition.N°propo = Posseder.N°propo" _
            & " WHERE ((([Commande Matériel Exxon].N°CommandeExxon)= " & N°Comm & " ));"
    J'ai juste rajouter un espace après les guillemets au retour de ligne, alors que sur d'autre requètes que je rentre dans des variables genre :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    SauvPropo = "SELECT [Commande Matériel Exxon].N°CommandeExxon, [Commande Matériel Exxon].Demandeur, [Commande Matériel Exxon].MatérielDemandé, [Commande Matériel Exxon].DateDébutExx, [Commande Matériel Exxon].DateFinExx, [Commande Matériel Exxon].NomProjetExxon, [Commande Matériel Exxon].[Nom Fournisseur], [Affaire SIE].N°AffaireSIE, [Affaire SIE].ChargéAffaire, [Affaire SIE].[Date Reception Propo], [Affaire SIE].[Date création affaire], [Affaire SIE].[Date fin affaire], [Affaire SIE].[Nombre d'heure attribuée], Matériel.[iD Matériel], Matériel.Repère, Matériel.Désignation, Posseder.[iD Matériel], Posseder.N°propo, Proposition.N°propo, Proposition.[Date Création propo], Comprendre.N°propo, Comprendre.[N°Type Action], Comprendre.[NB Heures pour une action], [Type action].Désignation INTO backupPropo IN 'C:\Transfert\La base\Archivage\Archivage.mdb'" _
            & "FROM (Proposition INNER JOIN ([Commande Matériel Exxon] INNER JOIN ([Affaire SIE] INNER JOIN (Matériel INNER JOIN Posseder ON Matériel.[iD Matériel] = Posseder.[iD Matériel]) ON [Affaire SIE].N°AffaireSIE = Matériel.N°AffaireSIE) ON [Commande Matériel Exxon].N°CommandeExxon = [Affaire SIE].N°CommandeExxon) ON Proposition.N°propo = Posseder.N°propo) INNER JOIN ([Type action] INNER JOIN Comprendre ON [Type action].[N°Type Action] = Comprendre.[N°Type Action]) ON Proposition.N°propo = Comprendre.N°propo " _
            & "WHERE ((([Commande Matériel Exxon].N°CommandeExxon)=" & N°Comm & "));"
    Il n'y a pas d'espace et ça marche très bien...
    c'est à n'y rien comprendre

  4. #4
    Membre régulier Avatar de Dryss51
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 113
    Points : 91
    Points
    91
    Par défaut
    Merci Domi je pense que tu avais parfaitement cerné le problème, d'ailleur dorénavant, je pense que j'utiliserai ta technique qui doit moins facilité les bugs d'espacement

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Requete Fusion sous Access
    Par askan dans le forum Access
    Réponses: 8
    Dernier message: 28/09/2006, 22h12
  2. Comment copier une feuille EXCEL sous ACCESS?
    Par PAULOM dans le forum Access
    Réponses: 7
    Dernier message: 28/04/2006, 10h01
  3. [sql]Probleme de count dans une requete sql (sous access)
    Par castelligreg dans le forum Requêtes et SQL.
    Réponses: 2
    Dernier message: 14/04/2006, 16h06
  4. Problème avec une requete SQL sous access
    Par Luther13 dans le forum Requêtes et SQL.
    Réponses: 12
    Dernier message: 14/12/2005, 10h39
  5. Réponses: 10
    Dernier message: 30/01/2005, 20h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo