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

IHM Discussion :

Erreur d'incompatibilité de type 13 [AC-2007]


Sujet :

IHM

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Mai 2009
    Messages : 111
    Points : 63
    Points
    63
    Par défaut Erreur d'incompatibilité de type 13
    Alors je me rappel que j'avai eu la même erreur il y a quelques temps mais je n'arrive pas a me souvenir comment j'avas réglé le problème et la je n'y arrive pas ...

    Voila le code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    Sub Totaux()
        Dim soustotal As Single
     
        soustotal = Me!FormTot1 + Me!FormTot2 + Me!FormTot3 + Me!FormTot4 + Me!FormTot5 + Me!FormTot6 + Me!FormTot7 + Me!FormTot8 + Me!FormTot9 + Me!FormTot10 + Me!FormTot11 + Me!FormTot12 + Me!FormTot13 + Me!FormTot14 + Me!FormTot15 + Me!FormTot16 + Me!FormTot17 + Me!FormTot18 + Me!FormTot19
        TxtSt.Value = soustotal
     
        TxtTTC.Value = Me!TxtSt - Me!TxtReduc
     
    End Sub
    Il bloque à la ligne soustotal = Me!FormTot1 + ...

    J'ai essayé de changé le type de soustotal en variant ( au cas ou ...) sans résultat , j'ai mis par défault 0 à tout les FormTot mais j'ai l'impression qu'il ne les prend pas quand je regarde dessus j'ai "" rien en fait ... je l'ai ai mis a 0 par default directement sur le formulaire puis dans le code avec :

    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
                FormTot1.Value = 0
                FormTot2.Value = 0
                FormTot3.Value = 0
                FormTot4.Value = 0
                FormTot5.Value = 0
                FormTot6.Value = 0
                FormTot7.Value = 0
                FormTot8.Value = 0
                FormTot9.Value = 0
                FormTot10.Value = 0
                FormTot11.Value = 0
                FormTot12.Value = 0
                FormTot13.Value = 0
                FormTot14.Value = 0
                FormTot15.Value = 0
                FormTot16.Value = 0
                FormTot17.Value = 0
                FormTot18.Value = 0
                FormTot19.Value = 0
    Mais cela ne change rien ...

    Cordialement

    Tristan

  2. #2
    Membre habitué Avatar de jimay
    Profil pro
    Inscrit en
    Août 2006
    Messages
    146
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Val d'Oise (Île de France)

    Informations forums :
    Inscription : Août 2006
    Messages : 146
    Points : 178
    Points
    178
    Par défaut
    Bonjour,

    Peut être qu'il faudrait "forcer" Access à prendre ces champs en tant que nombres en utilisant la fonction val() sur les Me!FormTotX ?

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Mai 2009
    Messages : 111
    Points : 63
    Points
    63
    Par défaut
    Non je vien de tester c'est la même erreur et il prennent "" comme valeur ...ce qui est étrange c'est que j'ai le même code sur un autre formulaire mais il prend bien les 0 comme valeur par default ...

  4. #4
    Membre habitué Avatar de jimay
    Profil pro
    Inscrit en
    Août 2006
    Messages
    146
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Val d'Oise (Île de France)

    Informations forums :
    Inscription : Août 2006
    Messages : 146
    Points : 178
    Points
    178
    Par défaut
    Bah désolé je ne vois pas trop..

    Peut être vérifier que les champs sont en mode "numérique" dans ton formulaire mais sinon aucune idée...

    désolé

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Mai 2009
    Messages : 111
    Points : 63
    Points
    63
    Par défaut
    C'est pas grave !

    Oui ils sont bien de type euro en faite maisbon c'est numérique et cela ne posait pas de souci à l'autre...

    Cordialement.

    Tristan.

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Mai 2009
    Messages : 111
    Points : 63
    Points
    63
    Par défaut
    J'arrive à mes fins avec se truc immonde :

    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
    Sub Totaux()
        Dim soustotal As Single
        Dim Reduc, Tot1, Tot2, Tot3, Tot4, Tot5, Tot6, Tot7, Tot8, Tot9, Tot10, Tot11, Tot12, Tot13, Tot14, Tot15, Tot16, Tot17, Tot18, Tot19 As Single
        If Me!FormTot1 <> "" Then
            Tot1 = Me!FormTot1
        End If
        If Me!FormTot1 = "" Then
            Tot1 = 0
        End If
        If Me!FormTot2 <> "" Then
            Tot2 = Me!FormTot2
        End If
        If Me!FormTot2 = "" Then
            Tot2 = 0
        End If
        If Me!FormTot3 <> "" Then
              Tot3 = Me!FormTot3
        End If
        If Me!FormTot3 = "" Then
            Tot3 = 0
        End If
        If Me!FormTot4 <> "" Then
              Tot4 = Me!FormTot4
        End If
        If Me!FormTot4 = "" Then
            Tot4 = 0
        End If
        If Me!FormTot5 <> "" Then
              Tot5 = Me!FormTot5
        End If
        If Me!FormTot5 = "" Then
            Tot5 = 0
        End If
        If Me!FormTot6 <> "" Then
              Tot6 = Me!FormTot6
        End If
        If Me!FormTot6 = "" Then
            Tot6 = 0
        End If
        If Me!FormTot7 <> "" Then
              Tot7 = Me!FormTot7
        End If
        If Me!FormTot7 = "" Then
            Tot7 = 0
        End If
        If Me!FormTot8 <> "" Then
              Tot8 = Me!FormTot8
        End If
        If Me!FormTot8 = "" Then
            Tot8 = 0
        End If
        If Me!FormTot9 <> "" Then
              Tot9 = Me!FormTot9
        End If
        If Me!FormTot9 = "" Then
            Tot9 = 0
        End If
        If Me!FormTot10 <> "" Then
              Tot10 = Me!FormTot10
        End If
        If Me!FormTot10 = "" Then
            Tot10 = 0
        End If
        If Me!FormTot11 <> "" Then
              Tot11 = Me!FormTot11
        End If
        If Me!FormTot11 = "" Then
            Tot11 = 0
        End If
        If Me!FormTot12 <> "" Then
              Tot12 = Me!FormTot12
        End If
        If Me!FormTot12 = "" Then
            Tot12 = 0
        End If
        If Me!FormTot13 <> "" Then
              Tot13 = Me!FormTot13
        End If
        If Me!FormTot13 = "" Then
            Tot13 = 0
        End If
        If Me!FormTot14 <> "" Then
              Tot14 = Me!FormTot14
        End If
        If Me!FormTot14 = "" Then
            Tot14 = 0
        End If
        If Me!FormTot15 <> "" Then
              Tot15 = Me!FormTot15
        End If
        If Me!FormTot15 = "" Then
            Tot15 = 0
        End If
        If Me!FormTot16 <> "" Then
              Tot16 = Me!FormTot16
        End If
        If Me!FormTot16 = "" Then
            Tot16 = 0
        End If
        If Me!FormTot17 <> "" Then
              Tot17 = Me!FormTot17
        End If
        If Me!FormTot17 = "" Then
            Tot17 = 0
        End If
        If Me!FormTot18 <> "" Then
              Tot18 = Me!FormTot18
        End If
        If Me!FormTot18 = "" Then
            Tot18 = 0
        End If
        If Me!FormTot19 <> "" Then
              Tot19 = Me!FormTot19
        End If
        If Me!FormTot19 = "" Then
            Tot19 = 0
        End If
     
     
     
        soustotal = Tot1 + Tot2 + Tot3 + Tot4 + Tot5 + Tot6 + Tot7 + Tot8 + Tot9 + Tot10 + Tot11 + Tot12 + Tot13 + Tot14 + Tot15 + Tot16 + Tot17 + Tot18 + Tot19
        TxtSt.Value = soustotal
        If Me!TxtReduc <> "" Then
            Reduc = Me!TxtReduc
        Else
            Reduc = 0
        End If
     
        TxtTTC.Value = Me!TxtSt - Reduc
     
    End Sub
    Donc bon c'est vraiment moche mais pas moyen de voir pourquoi il voulait pas les mettre à zero ...

  7. #7
    Expert éminent sénior

    Avatar de Tofalu
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Octobre 2004
    Messages
    9 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Octobre 2004
    Messages : 9 501
    Points : 32 311
    Points
    32 311
    Par défaut
    C'est logique, une chaine vide n'est pas 0, ni même une valeur Null.

    Attention au typage, dans ton code, seul Tot19 est single les autres ne sont pas typés.

    Le code peut s'alleger avec une boucle

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Sub Totaux()
        Dim soustotal As Currency
        Dim i As Integer
     
     
        For i = 1 To 19
            soustotal = soustotal + Val(Nz(Me.Controls("FormTot" & i).Value, 0))
        Next i
     
     
        TxtSt.Value = soustotal
        TxtTTC.Value = soustotal - Val(Nz(Me!TxtReduc, 0))
    End Sub
    Voire même se factoriser

    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
    Function ChaineVideAzero(V As Variant) As Currency
        ChaineVideAzero = Val(Nz(V, 0))
    End Function
     
    Sub Totaux()
        Dim soustotal As Currency
        Dim i As Integer
     
        For i = 1 To 19
            soustotal = soustotal + ChaineVideAzero(Me.Controls("FormTot" & i).Value)
        Next i
     
        TxtSt.Value = soustotal
        TxtTTC.Value = soustotal - ChaineVideAzero(Me!TxtReduc)
    End Sub

  8. #8
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Mai 2009
    Messages : 111
    Points : 63
    Points
    63
    Par défaut
    Merci Tofalu sa marche impecable j'avais pensais pensé (très vite) à faire une boucle mais je vu vite arrété par mon imcompétence à faite des concaténations en vb !

    Cordialement

    Tristan

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

Discussions similaires

  1. [A-07] Erreur n°13 : Incompatibilité de type
    Par Leimi dans le forum VBA Access
    Réponses: 2
    Dernier message: 17/03/2009, 11h15
  2. Erreur d'incompatibilité de types
    Par étoile de mer dans le forum Débuter
    Réponses: 27
    Dernier message: 01/06/2008, 17h14
  3. DLookup, Erreur d'incompatibilité de type (13)
    Par athos7776 dans le forum VBA Access
    Réponses: 5
    Dernier message: 08/08/2007, 17h25
  4. Erreur 13 : incompatibilité de type
    Par Donatelli dans le forum Access
    Réponses: 1
    Dernier message: 03/01/2007, 12h19
  5. [VBA-A] ADO - Erreur 13 Incompatibilité de Type
    Par db30 dans le forum VBA Access
    Réponses: 4
    Dernier message: 15/04/2006, 14h30

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