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 :

Creation de graphique croisé dynamique avec VBA Access 2010


Sujet :

IHM

  1. #1
    Membre à l'essai
    Femme Profil pro
    Inscrit en
    Juin 2011
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Juin 2011
    Messages : 17
    Points : 15
    Points
    15
    Par défaut Creation de graphique croisé dynamique avec VBA Access 2010
    Bonjour,
    Mon pbm est suivant: J'ai un formulaire qui paut s'affiche en graphique croisé dynamique.Chaque fois que je passe de mode datasheet au graphique croisé, toutes les données de series s'effacent, je dois refaire le graphique à nouveau. J'ai cherché sur les forums, mais il n'y a de solution a ce pbm encore, car apparemment c'est le bogue de cette version d'Access.
    Du coup, j'ai decidé de contourner ce pbm avec le code qui va me recreer le graphique chaque fois qu'un evenement precis se produit. J'ai trouvé ce code sur http://support.microsoft.com/kb/304143/fr et je l'ai adapté legerement a ma base. Le pbm, c'est qu'il ne marche pas. L'access me sort l'erreur "type Mismath" sur la ligne 19 "Set objChartSpace = frm.ChartSpace". Je ne comprends pas pourquoi. Peut-etre, vous aurez une explication?

    Voici le code:
    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
    Private Sub Command45_Click()
      Dim objPivotChart As ChChart
      Dim objChartSpace As ChartSpace
      Dim frm As Access.Form
      Dim strExpression As String
      Dim rs As Recordset
      Dim values
      Dim axCategoryAxis
      Dim axValueAxis
    
    DoCmd.OpenForm "Query4", acFormPivotChart, , , acFormPropertySettings, acWindowNormal
    
    
        Set frm = Forms("Query4")
      Set rs = frm.Recordset
           
      'Clear existing Charts on Form if present and add a new chart to the form.
      'Set object variable equal to the new chart.
      Set objChartSpace = frm.ChartSpace  objChartSpace.Clear
      objChartSpace.Charts.Add
      Set objPivotChart = objChartSpace.Charts.Item(0)
      
      'Set a variable to the Category (X) axis.
      Set axCategoryAxis = objChartSpace.Charts(0).Axes(0)
        
      ' Set a variable to the Value (Y) axis.
      Set axValueAxis = objChartSpace.Charts(0).Axes(1)
    
      ' The following two lines of code enable, and then
      ' set the title for the category axis.
      axCategoryAxis.HasTitle = True
      axCategoryAxis.Title.Caption = "RefYear"
        
      ' The following two lines of code enable, and then
      ' set the title for the value axis.
      axValueAxis.HasTitle = True
      axValueAxis.Title.Caption = "mln$"
        
      'Add Series to Chart and set the caption.
      objPivotChart.SeriesCollection.Add
      objPivotChart.SeriesCollection(0).Caption = "Data"
      
      'Add Data to the Series.
      objPivotChart.SeriesCollection(0).SetData chDimCategories, chDataLiteral, "RefYear"
      objPivotChart.SeriesCollection(0).SetData chDimValues, chDataLiteral, "Data"
      
      'Set focus to the form and destroy the form object from memory.
      frm.SetFocus
      Set frm = Nothing
      
    End Sub
    Merci d'avance

  2. #2
    Membre à l'essai
    Femme Profil pro
    Inscrit en
    Juin 2011
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Juin 2011
    Messages : 17
    Points : 15
    Points
    15
    Par défaut
    Bon, J'ai contourné le pbm.J'ai supprimé sur la ligne 2 et 3 "As ChChart" et "As ChartSpace"Maintenant ca marche en partie.

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

Discussions similaires

  1. [AC-2007] Graphique croisé dynamique en vba avec runtime
    Par guen dans le forum Runtime
    Réponses: 2
    Dernier message: 12/11/2012, 15h49
  2. Réponses: 2
    Dernier message: 24/06/2009, 23h28
  3. [AC-2003] Paramétrage de graphique croisé dynamique par VBA ?
    Par marot_r dans le forum IHM
    Réponses: 0
    Dernier message: 04/05/2009, 17h38
  4. Réponses: 2
    Dernier message: 22/12/2008, 10h40
  5. Réponses: 12
    Dernier message: 25/04/2007, 09h44

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