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

Modélisation Discussion :

Index ou clé primaire ne peut contenir valeur null [AC-2007]


Sujet :

Modélisation

  1. #1
    Membre habitué Avatar de C15nantes
    Homme Profil pro
    retraité
    Inscrit en
    Février 2011
    Messages
    379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : retraité
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2011
    Messages : 379
    Points : 137
    Points
    137
    Par défaut Index ou clé primaire ne peut contenir valeur null
    Bonjour à tous et à toutes.

    Pour la gestion d'une association, je suis en train de restructurer ma base.
    J'ai une T Adhérents avec N°Adherent/numérique/clé primaire incrémenté par du code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Private Sub Form_BeforeInsert(Cancel As Integer)
     
    N°Adherent = DLast("[N°Adherent]", "[T Adhérents]") + 1
     
    Dim Ctl As Control
        For Each Ctl In Forms![F Adhérents avec cotisations]![sfCotisations].Form.Détail.Controls
        If (Ctl.ControlType = acTextBox) Or (Ctl.ControlType = acComboBox) Or (Ctl.ControlType = acCheckBox) Then
        Ctl.Locked = False
        End If
        Next Ctl
     
     
    End Sub
    Cette table est reliée à 3 tables par N°Adherent/ Intégrité reférentielle
    TAG pour gérer les présences aux AG
    TCotisations pour gérer les cotisations
    TCotisationsdues pour gérer les dus.

    La T Adhérents est renseignée vis un formulaire
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    SELECT [T Adhérents].*, [T Adhérents].Adherent, [R Cotis_DuesAG].[Total dû]
    FROM [T Adhérents] INNER JOIN [R Cotis_DuesAG] ON [T Adhérents].N°Adherent = [R Cotis_DuesAG].N°Adherent
    WHERE ((([T Adhérents].Adherent)=True))
    ORDER BY [T Adhérents].Nom;
    dans ce formulaire j'ai un sous-formulaire sfCotisations (Champ père / champ fils = N°Adherent)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    SELECT [T Adhérents].N°Adherent, [T Adhérents].Nom, [T Adhérents].Prenom, [T Adhérents].Adherent, [T Adhérents].MiseAJour, [R Cotis_DuesAG].[Total dû], [T Adhérents].DateAdhesion, TCotisations.C87, TCotisations.C88, TCotisations.C89, TCotisations.C90, TCotisations.C91, TCotisations.C92, TCotisations.C93, TCotisations.C94, TCotisations.C95, TCotisations.C96, TCotisations.C97, TCotisations.C98, TCotisations.C99, TCotisations.C00, TCotisations.C01, TCotisations.C02, TCotisations.C03, TCotisations.C04, TCotisations.C05, TCotisations.C06, TCotisations.C07, TCotisations.C08, TCotisations.C09, TCotisations.C10, TCotisations.C11, TCotisations.C12, TCotisations.C13, TCotisations.C14, TCotisations.C15, TCotisations.C16, TCotisations.C17, TCotisations.C18, TCotisations.C19, TCotisations.C20, TCotisations.C21, TCotisations.C22, TCotisations.C23, TCotisations.C24, TCotisations.C25, TCotisations.C26, TCotisations.C27, TCotisations.C28, TCotisations.C29, TCotisations.C30, TCotisations.C31, TCotisations.C32, TCotisations.C33, TCotisations.C34, TCotisations.C35, TCotisationsdues.Du97, TCotisationsdues.Du98, TCotisationsdues.Du99, TCotisationsdues.Du00, TCotisationsdues.Du01, TCotisationsdues.Du02, TCotisationsdues.Du03, TCotisationsdues.Du04, TCotisationsdues.Du05, TCotisationsdues.Du06, TCotisationsdues.Du07, TCotisationsdues.Du08, TCotisationsdues.Du09, TCotisationsdues.Du10, TCotisationsdues.Du11, TCotisationsdues.Du12, TCotisationsdues.Du13, TCotisationsdues.Du14, TCotisationsdues.Du15, TCotisationsdues.Du16, TCotisationsdues.Du17, TCotisationsdues.Du18, TCotisationsdues.Du19, TCotisationsdues.Du20, TCotisationsdues.Du21, TCotisationsdues.Du22, TCotisationsdues.Du23, TCotisationsdues.Du24, TCotisationsdues.Du25, TCotisationsdues.Du26, TCotisationsdues.Du27, TCotisationsdues.Du28, TCotisationsdues.Du29, TCotisationsdues.Du30, TCotisationsdues.Du31, TCotisationsdues.Du32, TCotisationsdues.Du33, TCotisationsdues.Du34, TCotisationsdues.Du35
    FROM (([T Adhérents] INNER JOIN [R Cotis_DuesAG] ON [T Adhérents].N°Adherent = [R Cotis_DuesAG].N°Adherent) INNER JOIN TCotisations ON [T Adhérents].N°Adherent = TCotisations.N°Adherent) INNER JOIN TCotisationsdues ON [T Adhérents].N°Adherent = TCotisationsdues.N°Adherent
    WHERE ((([T Adhérents].Adherent)=True))
    ORDER BY [T Adhérents].Nom;

    Tout se passe bien par rapport aux enregistrements existants.
    Par contre, depuis peu, lorsque je veux enregistrer un nouvel adhérent, j'ai le message Index ou clé primaire ne peut contenir valeur null qui s'affiche.

    J'ai beau tourner et retourner mes procédures, je ne vois as ce qui se passe.

    Merci de votre aide.

    A+

    C15

  2. #2
    Membre éprouvé
    Inscrit en
    Août 2008
    Messages
    740
    Détails du profil
    Informations forums :
    Inscription : Août 2008
    Messages : 740
    Points : 1 045
    Points
    1 045
    Par défaut
    Bonjour,

    même si ton VBA est "before Insert", le système s'attend à trouver une valeur et donc affiche ce message

    il faut que tu autorises le null sur ce champ

  3. #3
    Membre habitué Avatar de C15nantes
    Homme Profil pro
    retraité
    Inscrit en
    Février 2011
    Messages
    379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : retraité
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2011
    Messages : 379
    Points : 137
    Points
    137
    Par défaut
    Bonjour

    Merci de cette réponse.
    J'avais bien oui, sans doublon sur ma clé primaire.

    Par contre en comparant cette base que je suis en train de remanier avec une base "soeur", d'une part j'ai nettoyé tout ce qui pouvait polluer, supprimer des options et cocher "compacter à la fermeture".

    Tout cela a fait que cela marche maintenant.

    A+
    C15

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

Discussions similaires

  1. Réponses: 9
    Dernier message: 08/08/2016, 15h52
  2. [AC-2007] un index ou une clé principale ne peut pas contenir une valeur null
    Par sarhouda dans le forum Access
    Réponses: 6
    Dernier message: 13/12/2012, 18h54
  3. jqgrid peut filtrer valeur null?
    Par laomaotou dans le forum jQuery
    Réponses: 0
    Dernier message: 14/09/2011, 15h06
  4. Le champs "X" ne peut contenir une valeur Null
    Par gentoo dans le forum Access
    Réponses: 4
    Dernier message: 18/03/2007, 23h41
  5. Réponses: 3
    Dernier message: 06/03/2007, 14h15

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