Soucis pour activé/désativé Bouton [Résolu]

Signaler
Messages postés
97
Date d'inscription
mercredi 9 décembre 2015
Statut
Membre
Dernière intervention
23 janvier 2021
-
Messages postés
18038
Date d'inscription
lundi 7 décembre 2009
Statut
Modérateur
Dernière intervention
11 avril 2018
-
Bonjour j'ai réalisé un bouton qui s'activera quand le champ "affectation" est sur affecté sinon il reste grisé
mais par contre quand je l'éxécute, je suis obligé d’allée sur la ligne d'en dessous pour que le bouton se grise et il devrait dégrisé un notre bouton voici les code
Private Sub Form_Current()
Me.Suprimer_Affectation.Enabled = IIf(Me.Statut_Affectation = "Affecté", True, False)
Me.Confirmer_Retour_Equipement.Enabled = IIf(Me.Statut_Affectation = "Attente Retour", True, False)
Me.Confirmer_Retour_Abonnement.Enabled = IIf(Me.Statut_Affectation = "Attente Retour Abo", True, False)
Me.Refresh

End Sub

Private Sub Suprimer_Affectation_Click()
Dim OuiNonAnnulé As Integer
Dim strmysql As String
Dim Numero_puce As String
Dim MyDate As Date
Dim RunMySQL As String
DoCmd.SetWarnings False

Numero_puce = Me.Num_SIM

OuiNonAnnulé = MsgBox("Est-ce que le matériel est déjà retourné ?", vbYesNoCancel)
If OuiNonAnnulé = vbYes Then
strmysql = "UPDATE Abonnements SET Abonnements.Statut_Abo = ""Non Affecté"""
strmysql = strmysql & " WHERE (Abonnements.Num_SIM = """
strmysql = strmysql & Numero_puce
strmysql = strmysql & """);"
Me.Statut_Affectation = "Non Affecté"
Me.Statut = "inactif"
Me.Actif = False
DoCmd.RunSQL strmysql

DoCmd.RunCommand acCmdSaveRecord


MyDate = Date$
User = Environ("USERNAME")
RunMySQL = "INSERT INTO [Arch_Affectation] (Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM, Date_Début, Date_Fin, Actif, Statut_Affectation, Commentaire, Auteur, Date_Maj, Desc_Action )"
RunMySQL = RunMySQL & " select Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM , Date_Début, #"
RunMySQL = RunMySQL & MyDate
RunMySQL = RunMySQL & "#, Actif, Statut_Affectation, Commentaire, """
RunMySQL = RunMySQL & User
RunMySQL = RunMySQL & """, #"
RunMySQL = RunMySQL & MyDate
RunMySQL = RunMySQL & "#, ""Supprimer Affectation"""
RunMySQL = RunMySQL & " FROM [Affectation] WHERE [Affectation].Or_Affectation =" & Me.Or_Affectation & ";"
DoCmd.RunSQL RunMySQL

DoCmd.RunSQL " UPDATE [Equipement] INNER JOIN [Affectation] ON [Equipement].Num_EMEI = [Affectation].Num_EMEI SET [Equipement].Statut_Equipement =""Non Affecté""" _
& " WHERE Equipement.Num_EMEI='" & Me.Num_EMEI & "'"
DoCmd.RunSQL " UPDATE [Employé] INNER JOIN [Affectation] ON [Employé].USER_ID = [Affectation].USER_ID SET [Employé].Statut =""Affecté""" _
& " WHERE Employé.USER_ID='" & Me.USER_ID & "'"

ElseIf OuiNonAnnulé = vbNo Then
strmysql = "UPDATE Abonnements SET Abonnements.Statut_Abo = ""Attente Retour"""
strmysql = strmysql & " WHERE (Abonnements.Num_SIM = """
strmysql = strmysql & Numero_puce
strmysql = strmysql & """);"
Me.Statut_Affectation = "Attente Retour"
DoCmd.RunSQL strmysql
DoCmd.RunCommand acCmdSaveRecord


MyDate = Date$
User = Environ("USERNAME")
RunMySQL = "INSERT INTO [Arch_Affectation] (Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM, Date_Début, Date_Fin, Actif, Statut_Affectation, Commentaire, Auteur, Date_Maj, Desc_Action )"
RunMySQL = RunMySQL & " select Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM , Date_Début, #"
RunMySQL = RunMySQL & MyDate
RunMySQL = RunMySQL & "#, Actif, Statut_Affectation, Commentaire,"""
RunMySQL = RunMySQL & User
RunMySQL = RunMySQL & """, #"
RunMySQL = RunMySQL & MyDate
RunMySQL = RunMySQL & "#, ""Supprimer Affectation - Attente Retour"""
RunMySQL = RunMySQL & " FROM [Affectation] WHERE [Affectation].Or_Affectation =" & Me.Or_Affectation & ";"
DoCmd.RunSQL RunMySQL

DoCmd.RunSQL " UPDATE [Equipement] INNER JOIN [Affectation] ON [Equipement].Num_EMEI = [Affectation].Num_EMEI SET [Equipement].Statut_Equipement =""Attente Retour""" _
& " WHERE Equipement.Num_EMEI='" & Me.Num_EMEI & "'"
ElseIf OuiNonAnnulé = vbAnnulé Then
End If
Me.Refresh
End Sub

Private Sub Confirmer_Retour_Equipement_Click()
Dim OuiNonAnnulé As Integer
Dim strmysql As String
Dim Numero_puce As String
Dim MyDate As Date
Dim RunMySQL As String

Numero_puce = Me.Num_SIM


OuiNonAnnulé = MsgBox("Est-ce que Vous confirmez aussi le Retour de l'abonnement ?", vbYesNoCancel)
If OuiNonAnnulé = vbYes Then
strmysql = "UPDATE Abonnements SET Abonnements.Statut_Abo = ""Non Affecté"""
strmysql = strmysql & " WHERE (Abonnements.Num_SIM = """
strmysql = strmysql & Numero_puce
strmysql = strmysql & """);"
Me.Statut_Affectation = "Non Affecté"
Me.Statut = "inactif"
Me.Actif = False
DoCmd.RunSQL strmysql
DoCmd.RunCommand acCmdSaveRecord

MyDate = Date$
User = Environ("USERNAME")
RunMySQL = "INSERT INTO [Arch_Affectation] (Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM, Date_Début, Date_Fin, Actif, Statut_Affectation, Commentaire, Auteur, Date_Maj, Desc_Action )"
RunMySQL = RunMySQL & " select Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM , Date_Début, #"
RunMySQL = RunMySQL & MyDate
RunMySQL = RunMySQL & "#, Actif, Statut_Affectation, Commentaire,"""
RunMySQL = RunMySQL & User
RunMySQL = RunMySQL & """, #"
RunMySQL = RunMySQL & MyDate
RunMySQL = RunMySQL & "#, ""Confirmation Retour"""
RunMySQL = RunMySQL & " FROM [Affectation] WHERE [Affectation].Or_Affectation =" & Me.Or_Affectation & ";"
DoCmd.RunSQL RunMySQL

DoCmd.RunSQL " UPDATE [Equipement] INNER JOIN [Affectation] ON [Equipement].Num_EMEI = [Affectation].Num_EMEI SET [Equipement].Statut_Equipement =""Non Affecté""" _
& " WHERE Equipement.Num_EMEI='" & Me.Num_EMEI & "'"

ElseIf OuiNonAnnulé = vbNo Then
strmysql = "UPDATE Abonnements SET Abonnements.Statut_Abo = ""Attente Retour Abo"""
strmysql = strmysql & " WHERE (Abonnements.Num_SIM = """
strmysql = strmysql & Numero_puce
strmysql = strmysql & """);"
Me.Statut_Affectation = "Attente Retour Abo"
DoCmd.RunSQL strmysql
DoCmd.RunCommand acCmdSaveRecord

MyDate = Date$
User = Environ("USERNAME")
RunMySQL = "INSERT INTO [Arch_Affectation] (Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM, Date_Début, Date_Fin, Actif, Statut_Affectation, Commentaire, Auteur, Date_Maj, Desc_Action )"
RunMySQL = RunMySQL & " select Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM , Date_Début, #"
RunMySQL = RunMySQL & MyDate
RunMySQL = RunMySQL & "#, Actif, Statut_Affectation, Commentaire,"""
RunMySQL = RunMySQL & User
RunMySQL = RunMySQL & """, #"
RunMySQL = RunMySQL & MyDate
RunMySQL = RunMySQL & "#, ""Supprimer Affectation - Retour Equipement"""
RunMySQL = RunMySQL & " FROM [Affectation] WHERE [Affectation].Or_Affectation =" & Me.Or_Affectation & ";"
DoCmd.RunSQL RunMySQL
DoCmd.RunSQL " UPDATE [Equipement] INNER JOIN [Affectation] ON [Equipement].Num_EMEI = [Affectation].Num_EMEI SET [Equipement].Statut_Equipement =""Non Affecté""" _
& " WHERE Equipement.Num_EMEI='" & Me.Num_EMEI & "'"

ElseIf OuiNonAnnulé = vbAnnulé Then
End If
Me.Refresh

End Sub

Private Sub Confirmer_Retour_Abonnement_Click()
Dim strmysql As String
Dim Numero_puce As String
Dim MyDate As Date
Dim RunMySQL As String

Numero_puce = Me.Num_SIM
User = Environ("USERNAME")

DoCmd.SetWarnings False

strmysql = "UPDATE Abonnements SET Abonnements.Statut_Abo = ""Non Affecté"""
strmysql = strmysql & " WHERE (Abonnements.Num_SIM = """
strmysql = strmysql & Numero_puce
strmysql = strmysql & """);"
Me.Statut_Affectation = "Non Affecté"
Me.Statut = "inactif"
Me.Actif = False
DoCmd.RunSQL strmysql
DoCmd.RunCommand acCmdSaveRecord

MyDate = Date
RunMySQL = "INSERT INTO [Arch_Affectation] (Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM, Date_Début, Date_Fin, Actif, Statut_Affectation, Commentaire, Auteur, Date_Maj, Desc_Action )"
RunMySQL = RunMySQL & " select Or_Affectation, USER_ID, PIN_Terminal, PIN_SIM, Coque, Vitre, Support_Vehicule, Num_EMEI,Num_SIM , Date_Début, #"
RunMySQL = RunMySQL & MyDate
RunMySQL = RunMySQL & "#, Actif, Statut_Affectation, Commentaire,"""
RunMySQL = RunMySQL & User
RunMySQL = RunMySQL & """, #"
RunMySQL = RunMySQL & MyDate
RunMySQL = RunMySQL & "#, ""Supprimer Affectation - Retour Abonnement"""
RunMySQL = RunMySQL & " FROM [Affectation] WHERE [Affectation].Or_Affectation =" & Me.Or_Affectation & ";"
DoCmd.RunSQL RunMySQL
Me.Refresh

End Sub



Merci

1 réponse

Messages postés
18038
Date d'inscription
lundi 7 décembre 2009
Statut
Modérateur
Dernière intervention
11 avril 2018
236
Bonjour,
Veux-tu bien isoler le code concerné par la difficulté rencontrée ,
Elle est inutilement noyée dans le code/roman joint, qui ne donne pas du tout envie de rechercher dans laquelle de ses parties se trouve celle objet de cette discussion.