Fonction afterupdate ne ce reactualise pas

simbabou Messages postés 31 Date d'inscription mardi 19 décembre 2000 Statut Membre Dernière intervention 17 novembre 2016 - 20 août 2008 à 15:55
simbabou Messages postés 31 Date d'inscription mardi 19 décembre 2000 Statut Membre Dernière intervention 17 novembre 2016 - 21 août 2008 à 11:26
bonjour
j'ai créé une petite procédure tte simple pour un afterupdate d'une zone de texte
Public Sub Ref1_AfterUpdate()
    If IsNull(Ref1) = False Then
        Ref2 = Null
        Ref2.Visible = False
    Else
        Ref2.Visible = True
    End If
End Sub

lorsque je fait les modification sur le code et que je teste sans fermer le formulaire la procédure fonctionne bien mais dés que je la ferme et la réouvre elle ne fonctionne plus comme si le code ne passait plus par cette procédure.si quelqu'un pouvait m'aider ce serait sympa
merci

5 réponses

lillith212 Messages postés 1229 Date d'inscription vendredi 16 novembre 2007 Statut Membre Dernière intervention 16 juin 2009
21 août 2008 à 09:15
Salut,

Tu l'appelles à quelle occasion ta procédure?
Peux tu donner aussi ce code?

Merci

S.L.B.

<hr />*********************************************************************************
<>
0
simbabou Messages postés 31 Date d'inscription mardi 19 décembre 2000 Statut Membre Dernière intervention 17 novembre 2016
21 août 2008 à 10:00
comment ça je l'appelle a quelle occasion ?
elle est dans ma page de code de mon formulaire access, normalement elle est utilisé lorsque ma zone de texte "Ref1" est changée mais si effectivement faut l'appeler quelque part dans le code mon probleme vient peut être de la !!
par contre si il faut l'appeler, le nouveau probleme c'est comment faire ??!!!
0
lillith212 Messages postés 1229 Date d'inscription vendredi 16 novembre 2007 Statut Membre Dernière intervention 16 juin 2009
21 août 2008 à 10:53
Salut,
peux tu donner le code ?
Je pense que ce sera plus facile pour t'aider

S.L.B.

<hr />*********************************************************************************
<>
0
lillith212 Messages postés 1229 Date d'inscription vendredi 16 novembre 2007 Statut Membre Dernière intervention 16 juin 2009
21 août 2008 à 10:54
Re:
Juste une question. Tu développes en vb.net??? ou vb2005???

S.L.B.

<hr />*********************************************************************************
<>
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
simbabou Messages postés 31 Date d'inscription mardi 19 décembre 2000 Statut Membre Dernière intervention 17 novembre 2016
21 août 2008 à 11:26
je développe en visual basic 6.3 sinon voici mon code  :
Option Explicit
Public Sub RAZ_Critere()
    'init des critères    Ref1 Null: Ref2 Null
    Liste.Requery: Ligne1.Requery
End Sub
Public Sub Traitement_choix(WType As String, WCle As String)
    On Error GoTo Erreur
   
    Dim ReqString As String, WReponse As Long
    Dim NumNoOF As Long
    Dim NumNoOP As Long
    Dim NumNoPoste As Long
    Dim NumNoMachine As Long
    Dim NumDebut As Date
    NumNoOF = Liste.Column(1)
    NumNoOP = Liste.Column(2)
    NumNoPoste = Liste.Column(3)
    NumNoMachine = Liste.Column(4)
    NumDebut = Liste.Column(5)
    Dim Date6 As Variant, Date7 As Variant
     'Traitement date nulle
            If IsNull(Ligne6) Then
            Date6 = #1/1/1988#
            Else
            Date6 = Ligne6
            End If
             If IsNull(Ligne7) Then
            Date7 = #1/1/1988#
            Else
            Date7 = Ligne7
            End If
   
    'selection du type de traitement
    Select Case WType
        Case "S" 'sélection            ReqString "SELECT NoBadge FROM Evt_Salarie WHERE NoBadge " & WCle & " And NoOF = " & NumNoOF & " And NoOP = " & NumNoOP & " And NoPoste = " & NumNoPoste & " And NoMachine = " & NumNoMachine & " and Debut = #" & Format(NumDebut, "mm/dd/yyyy hh:nn:ss") & "#"
            If Execute_Requete(ReqString, "S") = 0 Then
                 RAZ False
                 Ligne1 = WCle
                 Ligne2.SetFocus
                 MAJ_Bouton True, False, False
               Else 'Enregistrement trouvé
                 ReqString = "SELECT NoBadge, NoOF, NoOP, NoPoste, NoMachine, Debut, Fin" & ", "
                 ReqString = ReqString & "Coefficient , NoActivite, Mois, Semaine, SecteurNC, DefautNC, Reouverture" & ", "                 ReqString ReqString & "Anomalie FROM Evt_Salarie WHERE NoBadge " & WCle & " And NoOF = " & NumNoOF & " And NoOP = " & NumNoOP & " And NoPoste = " & NumNoPoste & " And NoMachine = " & NumNoMachine & " and Debut = #" & Format(NumDebut, "mm/dd/yyyy hh:nn:ss") & "#"
                       Affiche_Enreg ReqString, Me.Name 'procedure d'affichage dans les champs du formulaire (Ligne1 ....Ligne N)
                 MAJ_Bouton False, True, True
            End If
        Case "D" 'suppression
            If MsgBox("Confirmer la Suppression de cette fiche", 20) = vbYes Then               ReqString "DELETE FROM Evt_Salarie WHERE NoBadge " & WCle & " And NoOF = " & NumNoOF & " And NoOP = " & NumNoOP & " And NoPoste = " & NumNoPoste & " And NoMachine = " & NumNoMachine & " and Debut = #" & Format(NumDebut, "mm/dd/yyyy hh:nn:ss") & "#"
               Execute_Requete ReqString, "D"
               'mise à jour des boutons
               Ligne1.SetFocus
               MAJ_Bouton False, False, False
               'init des zones de saisie
               RAZ True
               Ligne1.Requery: Liste.Requery
            End If
        Case "U" 'mise à jour            ReqString "UPDATE Evt_Salarie SET NoOF " & IIf(IsNull(Ligne2), "Null", Ligne2) & ", "            ReqString ReqString & "NoOP " & IIf(IsNull(Ligne3), "Null", Ligne3) & ", "            ReqString ReqString & "NoPoste " & IIf(IsNull(Ligne4), "Null", Ligne4) & ", "            ReqString ReqString & "NoMachine " & IIf(IsNull(Ligne5), "Null", Ligne5) & ", "            ReqString ReqString & "Debut " & IIf(Date6 = #1/1/1988#, "Null", """" & DateValue(Date6) & " " & TimeValue(Date6) & """") & ", "            ReqString ReqString & "Fin " & IIf(Date7 = #1/1/1988#, "Null", """" & DateValue(Date7) & " " & TimeValue(Date7) & """") & ", "            ReqString ReqString & "Coefficient " & IIf(IsNull(Ligne8), "1 ", Ligne8) & ", "            ReqString ReqString & "NoActivite " & IIf(IsNull(Ligne9), "PROD ", """" & Left(Ligne9, 10) & """") & ", "            ReqString ReqString & "Mois " & IIf(IsNull(Ligne10), "Null", Ligne10) & ", "            ReqString ReqString & "Semaine " & IIf(IsNull(Ligne11), "Null", Ligne11) & ", "            ReqString ReqString & "SecteurNC " & IIf(IsNull(Ligne12), "Z ", """" & Left(Ligne12, 2) & """") & ", "            ReqString ReqString & "DefautNC " & IIf(IsNull(Ligne13), "0 ", Ligne13) & ", "            ReqString ReqString & "Reouverture " & IIf(IsNull(Ligne14), "0 ", Ligne14) & ", "            ReqString ReqString & "Anomalie " & IIf(IsNull(Ligne15), "0 ", Ligne15)            ReqString ReqString & " WHERE NoBadge " & WCle & " And NoOF = " & NumNoOF & " And NoOP = " & NumNoOP & " And NoPoste = " & NumNoPoste & " And NoMachine = " & NumNoMachine & " and Debut = #" & Format(NumDebut, "mm/dd/yyyy hh:nn:ss") & "#"
            Execute_Requete ReqString, "U"
            'Mise à jour des boutons
            Ligne1.SetFocus
            MAJ_Bouton False, True, True
            Ligne1.Requery: Liste.Requery
    End Select
    Exit Sub
   
Erreur:
    MsgBox "Erreur N° " & Err.Number & " - " & Err.Description
End Sub

Private Sub Ref1_AfterUpdate()
    If IsNull(Ref1) = False Then
        Ref2 = Null
        Ref2.Visible = False
    Else
        Ref2.Visible = True
    End If
End Sub

Private Sub Ref2_AfterUpdate()
    If IsNull(Ref2) = False Then
        Ref1 = Null
        Ref1.Visible = False
    Else
        Ref1.Visible = True
    End If
End Sub

Public Sub MAJ_Bouton(Flag_Ajout As Boolean, Flag_Supp As Boolean, Flag_MAJ As Boolean)
         Btn_Ajouter.Enabled = Flag_Ajout
         Btn_Modifier.Enabled = Flag_MAJ
         Btn_Supprimer.Enabled = Flag_Supp
End Sub

Public Sub RAZ(WCode As Boolean)
    'initialise les zones de saisie
    If WCode Then Ligne1 = Null    Ligne2 Null: Ligne3 Null    Ligne4 Null: Ligne5 Null    Ligne6 Now(): Ligne7 Now()    Ligne8 1: Ligne9 "PROD"    Ligne10 Year(Now) & Month(Now): Ligne11 Year(Now) & DatePart("ww", Now, 2, 3)    Ligne12 "Z": Ligne13 0    Ligne14 0: Ligne15 0
End Sub

Private Sub Btn_Ajouter_Click()
    Trait_choix "I", Ligne1
End Sub

Private Sub Btn_Editer_Click()
    Dim DefaultReport As String
    DefaultReport = "Ed_EVT_Salarie"
    DoCmd.OpenReport IIf(IsNull(NomEtat), DefaultReport, NomEtat), IIf(Apercu.Value, acViewPreview, acViewNormal)
    DoCmd.Maximize
End Sub

Private Sub Btn_Fermer_Click()
    DoCmd.Close
End Sub

Private Sub Btn_Modifier_Click()
    Traitement_choix "U", Ligne1
End Sub

Private Sub Btn_Supprimer_Click()
    Traitement_choix "D", Ligne1
End Sub

Private Sub Commande147_Click()
    If IsNull(Ref2) And IsNull(Ref1) = False Then
    DoCmd.OpenForm "DT_EVT_Machine", , , , , , Ref1
    DoCmd.Close acForm, "DT_EVT_Salarie", acSaveYes
    Else
    Liste.Requery: Ligne1.Requery
    End If
End Sub

Private Sub Commande148_Click()
    RAZ_Critere
End Sub

Private Sub Form_Open(Cancel As Integer)
   
    'init des zones de saisie
    RAZ True

    'maj des boutons
    MAJ_Bouton False, False, False
   
    'maj des criteres
    RAZ_Critere
   
    Ref2 = OpenArgs
    Liste.Requery
   
    'maj du titre de l'application
    Me.Caption = "Evenements"
End Sub

Private Sub Quitter_Click()
    DoCmd.Close
End Sub

Private Sub Ligne1_AfterUpdate()
    Trait_choix "S", Ligne1
End Sub

Private Sub Liste_Click()
    Traitement_choix "S", Liste
End Sub
Public Sub Trait_choix(WType As String, WCle As String)
    On Error GoTo Erreur
   
    Dim ReqString As String, WReponse As Long
    Dim NumNoOF As Long
    Dim NumNoOP As Long
    Dim NumNoPoste As Long
    Dim NumNoMachine As Long
    Dim NumDebut As Date
    NumNoOF = 0
    NumNoOP = 0
    NumNoPoste = 0
    NumNoMachine = 0
    NumDebut = Now()
    Dim Date6 As Variant, Date7 As Variant
     'Traitement date nulle
            If IsNull(Ligne6) Then
            Date6 = #1/1/1988#
            Else
            Date6 = Ligne6
            End If
             If IsNull(Ligne7) Then
            Date7 = #1/1/1988#
            Else
            Date7 = Ligne7
            End If
   
    'selection du type de traitement
    Select Case WType
        Case "S" 'sélection            ReqString "SELECT NoBadge FROM Evt_Salarie WHERE NoBadge " & WCle & " And NoOF = " & NumNoOF & " And NoOP = " & NumNoOP & " And NoPoste = " & NumNoPoste & " And NoMachine = " & NumNoMachine & " and Debut = #" & Format(NumDebut, "mm/dd/yyyy hh:nn:ss") & "#"
            If Execute_Requete(ReqString, "S") = 0 Then
                 RAZ False
                 Ligne1 = WCle
                 Ligne2.SetFocus
                 MAJ_Bouton True, False, False
               Else 'Enregistrement trouvé
                 ReqString = "SELECT NoBadge, NoOF, NoOP, NoPoste, NoMachine, Debut, Fin" & ", "
                 ReqString = ReqString & "Coefficient , NoActivite, Mois, Semaine, SecteurNC, DefautNC, Reouverture" & ", "                 ReqString ReqString & "Anomalie FROM Evt_Salarie WHERE NoBadge " & WCle & " And NoOF = " & NumNoOF & " And NoOP = " & NumNoOP & " And NoPoste = " & NumNoPoste & " And NoMachine = " & NumNoMachine & " and Debut = #" & Format(NumDebut, "mm/dd/yyyy hh:nn:ss") & "#"
                       Affiche_Enreg ReqString, Me.Name 'procedure d'affichage dans les champs du formulaire (Ligne1 ....Ligne N)
                 MAJ_Bouton False, True, True
            End If
        Case "I" 'ajout
            ReqString = "INSERT INTO Evt_Salarie VALUES (" & WCle & ", "
            ReqString = ReqString & IIf(IsNull(Ligne2), "Null", Ligne2) & ", "
            ReqString = ReqString & IIf(IsNull(Ligne3), "Null", Ligne3) & ", "
            ReqString = ReqString & IIf(IsNull(Ligne4), "Null", Ligne4) & ", "
            ReqString = ReqString & IIf(IsNull(Ligne5), "Null", Ligne5) & ", "            ReqString ReqString & IIf(Date6 #1/1/1988#, "Null", """" & DateValue(Date6) & " " & TimeValue(Date6) & """") & ", "            ReqString ReqString & IIf(Date7 #1/1/1988#, "Null", """" & DateValue(Date7) & " " & TimeValue(Date7) & """") & ", "
            ReqString = ReqString & IIf(IsNull(Ligne8), "1 ", Ligne8) & ", "
            ReqString = ReqString & IIf(IsNull(Ligne9), "PROD ", """" & Left(Ligne9, 10) & """") & ", "
            ReqString = ReqString & IIf(IsNull(Ligne10), "Null", Ligne10) & ", "
            ReqString = ReqString & IIf(IsNull(Ligne11), "Null", Ligne11) & ", "
            ReqString = ReqString & IIf(IsNull(Ligne12), "Z ", """" & Left(Ligne12, 2) & """") & ", "
            ReqString = ReqString & IIf(IsNull(Ligne13), "0 ", Ligne13) & ", "
            ReqString = ReqString & IIf(IsNull(Ligne14), "0 ", Ligne14) & ", "
            ReqString = ReqString & IIf(IsNull(Ligne15), "0 ", Ligne15) & ")"
            Execute_Requete ReqString, "I"
            'changement de l'état des boutons
            Ligne1.SetFocus
            MAJ_Bouton False, True, True
            Ligne1.Requery: Liste.Requery
    End Select
    Exit Sub
   
Erreur:
    MsgBox "Erreur N° " & Err.Number & " - " & Err.Description
End Sub
0
Rejoignez-nous