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

Access Discussion :

Problème d'INSERT


Sujet :

Access

  1. #1
    Membre actif Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 319
    Points : 286
    Points
    286
    Par défaut Problème d'INSERT
    Salut la compagnie...
    J'ai beau chercher dans le forum, je ne trouve pas ce que je veux mais je suis presque sur que je ne dois pas utiliser les bons mots
    Voici donc mon petit problème : lorsque je sors du premier champs de mon forumlaire, l'ajout dans la table se fait, sans message alors que je voudrai que ça passe obligatoirement par le clic sur le bouton validation.
    Est-ce qu'il y a donc un moyen de ne pas avoir d'inert dans les tables de manière automatique ?
    Zeb'...

  2. #2
    Membre chevronné
    Avatar de Demco
    Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 396
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 396
    Points : 2 228
    Points
    2 228
    Par défaut
    Je pense que ce lien te donnera une réponse.

    En espérant t'aider.
    J'aime les gâteaux.

  3. #3
    Membre actif Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 319
    Points : 286
    Points
    286
    Par défaut
    Malheureusement non, car j'ai du code dans le Before_Update.
    Je vous met tout le code de mon forumlaire (qui n'est pas trop long) en espérant que vous pourrez m'aider, voir me corriger, car je début de chez début en Access...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
     
    Option Compare Database
     
    Private Function Trt_Existe(Code_Oaci As String) As Boolean
        Dim RS As Recordset
     
        On Error GoTo Err_Num
     
        WCode_OACI = Ajout_Quote(Trim(UCase(Code_Oaci)))
        WRequete = "Select * from COM where COM.C_OACI = " & WCode_OACI
        Set RS = CurrentDb.OpenRecordset(WRequete, 2)
     
        With RS
            .OpenRecordset
            If .RecordCount > 0 Then
                Trt_Existe = True
            End If
            .Close
        End With
     
    Sortie_Num:
        Set RS = Nothing
        Exit Function
    Err_Num:
        Trt_Existe = False
        Resume Sortie_Num
    End Function
     
     
    Private Sub B_Annulation_Click()
        Call Form_Load
        B_Annulation.Visible = False
        B_Validation.Visible = False
    End Sub
     
    Private Sub B_Validation_Click()
        If MsgBox("Enregistrement de la saisie en cours ?", vbYesNo + vbQuestion, "Validation ?") = vbYes Then
    ' Vérifications de la saisie
    ' INSERT de la saisie
    ' préparation à la saisie d'un nouvel enregistrement
            WOACI = Ajout_Quote(Trim(UCase(C_OACI)))
            WADP = Ajout_Quote(Trim(UCase(C_ADP)))
            WEXCOD = Ajout_Quote(Trim(UCase(C_EXCOD)))
            WLIB = Ajout_Quote(Trim(UCase(C_LIB)))
            WLAND = Ajout_Quote(Trim(UCase(C_LAND)))
     
            WInsert = "insert into COM values (" & WOACI & "," & WADP & "," & WEXCOD & "," & WLIB & "," & WLAND & ")"
            DoCmd.RunSQL (WInsert)
     
            Call B_AjouterCompagnie_Click
        Else
            MsgBox "Enregistrement annulé."
            C_OACI.SetFocus
        End If
    End Sub
     
    Private Sub Form_BeforeUpdate(Cancel As Integer)
        If Not IsNull(C_OACI) Then
            If Trt_Existe(C_OACI.Value) Then
                MsgBox "Ce code OACI existe déjà dans la table."
                Cancel = True
                C_OACI.SetFocus
            Else
                Cancel = False
            End If
        Else
            MsgBox ("Le champ 'Code OACI' ne peut pas être vide.")
            C_OACI.SetFocus
        End If
    End Sub
     
    Private Sub Form_AfterInsert()
        MsgBox "Ajout effectué."
        C_OACI.Locked = True
        C_ADP.Locked = True
        C_EXCOD.Locked = True
        C_LAND.Locked = True
        C_LIB.Locked = True
     
        C_Compagnie.Value = ""
        C_Compagnie.Locked = False
        C_Compagnie.SetFocus
     
        B_Validation.Visible = False
        B_Annulation.Visible = False
        Me.AllowAdditions = False
     
    End Sub
     
    Private Sub C_Compagnie_AfterUpdate()
        ' Rechercher l'enregistrement correspondant au contrôle.
        Dim RS As Object
     
        Set RS = Me.Recordset.Clone
        RS.FindFirst "[C_OACI] = '" & Me![C_Compagnie] & "'"
        If Not RS.EOF Then Me.Bookmark = RS.Bookmark
    End Sub
     
    Private Sub B_AjouterCompagnie_Click()
    On Error GoTo Err_B_AjouterCompagnie_Click
    ' il faut déverrouiller tous les champs
        C_OACI.Locked = False
        C_ADP.Locked = False
        C_EXCOD.Locked = False
        C_LAND.Locked = False
        C_LIB.Locked = False
     
        C_Compagnie.Value = ""
        C_Compagnie.Locked = True
        C_OACI.SetFocus
     
        B_Validation.Visible = True
        B_Annulation.Visible = True
        Me.AllowAdditions = True
        DoCmd.GoToRecord , , acNewRec
     
    Exit_B_AjouterCompagnie_Click:
        Exit Sub
     
    Err_B_AjouterCompagnie_Click:
        MsgBox Err.Description
        Resume Exit_B_AjouterCompagnie_Click
     
    End Sub
     
    Private Sub B_QuitterCompagnie_Click()
    On Error GoTo Err_B_QuitterCompagnie_Click
     
        If MsgBox("Annuler l'opération en cours et quitter le formulaire ?", vbQuestion + vbYesNo, "Sorite ?") = vbYes Then
            DoCmd.Close
        End If
     
    Exit_B_QuitterCompagnie_Click:
        Exit Sub
     
    Err_B_QuitterCompagnie_Click:
        MsgBox Err.Description
        Resume Exit_B_QuitterCompagnie_Click
     
    End Sub
     
    Private Sub B_SupprimerCompagnie_Click()
    On Error GoTo Err_B_SupprimerCompagnie_Click
     
        If MsgBox("Suppression de la compagnie en cours ?", vbQuestion + vbYesNo, "Suppression ?") = vbYes Then
            DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
            DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
        End If
     
    Exit_B_SupprimerCompagnie_Click:
        Exit Sub
     
    Err_B_SupprimerCompagnie_Click:
        MsgBox Err.Description
        Resume Exit_B_SupprimerCompagnie_Click
     
    End Sub
     
    Private Sub Form_Load()
        DoCmd.SetWarnings False
        Me.AllowAdditions = False
        C_OACI.Locked = True
        C_ADP.Locked = True
        C_EXCOD.Locked = True
        C_LAND.Locked = True
        C_LIB.Locked = True
        C_Compagnie.Value = ""
        C_Compagnie.Locked = False
        C_Compagnie.SetFocus
    End Sub
     
    Private Sub Form_Unload(Cancel As Integer)
        DoCmd.SetWarnings True
    End Sub
     
    Private Function Ajout_Quote(P_Valeur)
        WValeur = "'" & P_Valeur & "'"
        Ajout_Quote = WValeur
    End Function
    Merci d'avance...
    Zeb'...

Discussions similaires

  1. problème d'insertion de données
    Par Falgan dans le forum ASP
    Réponses: 2
    Dernier message: 06/04/2004, 09h29
  2. Probléme d'insertion par défault
    Par xavier62 dans le forum SQL
    Réponses: 7
    Dernier message: 28/11/2003, 13h03
  3. [Interbase 7] Problème d'insertion de données
    Par Tuscelan dans le forum InterBase
    Réponses: 12
    Dernier message: 19/11/2003, 22h58
  4. STL : std::set problème avec insert ...
    Par Big K. dans le forum MFC
    Réponses: 13
    Dernier message: 08/11/2003, 01h02
  5. Problème d'insertion avec MySQL
    Par Sonny dans le forum ASP
    Réponses: 13
    Dernier message: 28/08/2003, 13h52

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