Afficher UF en fonction de coches

Résolu
thesentry Messages postés 1092 Statut Membre -  
thesentry Messages postés 1092 Statut Membre -
Bonjour,

J'ai 3 coches sur un UF. En fonction de ceux qui sont cochés, je veux faire apparaître un UF bien particulier.

Je suis un gros nul en VBA, je débute. Voici mon code :

Private Sub CommandButton1_Click()

If CheckBox1.Value = CheckBox2.Value = CheckBox3.Value = 1 Then NRASRZSRIPCCT.Show
If CheckBox1.Value = CheckBox2.Value = 1 Then NRASRZSRICT.Show
If CheckBox1.Value = 1 Then NRASRZCT.Show
If CheckBox2.Value = CheckBox3.Value = 1 Then NRASRIPCCT.Show
If CheckBox2.Value = 1 Then NRASRICT.Show

End Sub

Où sont les problèmes ?

Merci d'avance

3 réponses

  1. thesentry Messages postés 1092 Statut Membre 16
     
    Bon ça a marché en remplaçant "1" par "True" sauf que bien sûr, cela m'a ouvert quasi tous les UF. Logique puisque j'ai que du IF.

    J'ai essayé If
    ElseIf
    ElseIf
    ...
    Else
    End If

    mais ça ne marche pas non plus
    0
  2. f894009 Messages postés 17417 Date d'inscription   Statut Membre Dernière intervention   1 717
     
    Bonjour,

    Private Sub CommandButton1_Click()

    If CheckBox1 And CheckBox2 And CheckBox3 Then
    NRASRZSRIPCCT.Show
    ElseIf CheckBox1 And CheckBox2 And Not CheckBox3 Then
    NRASRZSRICT.Show
    ElseIf CheckBox1 And Not (CheckBox2 And CheckBox3) Then
    NRASRZCT.Show
    ElseIf CheckBox2 And Not (CheckBox1 And CheckBox3) Then
    NRASRIPCCT.Show
    ElseIf CheckBox3 And Not (CheckBox1 And CheckBox2) Then
    NRASRICT.Show
    Else
    End If

    End Sub
    0
    1. thesentry Messages postés 1092 Statut Membre 16
       
      Bonjour,

      Super !

      Merci beaucoup !
      0
  3. Polux31 Messages postés 7219 Statut Membre 1 204
     
    Bonjour,

    S'il n'est possible d'ouvrir qu'un et un seul UF, il vaut mieux utiliser des "OptionButton" qui ne permettent qu'un seul choix.

    Exemple :

    Private Sub OptionButton1_Click()
        If OptionButton1.Value = True Then
            UF1.Show
        End If
    End Sub


    ;0)

    «Ce que l'on conçoit bien s'énonce clairement, Et les mots pour le dire arrivent aisément.»
    Nicolas Boileau
    0