Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Access > IHM
IHM Ce forum est dédié aux questions relatives à la création de formulaires et d'états, avec ou sans code VBA, et macros.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 25/07/2011, 15h25   #1
Invité régulier
 
Femme
Inscription : juin 2011
Messages : 17
Détails du profil
Informations personnelles :
Sexe : Femme

Informations forums :
Inscription : juin 2011
Messages : 17
Points : 6
Points : 6
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 :
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
sabinaS est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/07/2011, 13h41   #2
Invité régulier
 
Femme
Inscription : juin 2011
Messages : 17
Détails du profil
Informations personnelles :
Sexe : Femme

Informations forums :
Inscription : juin 2011
Messages : 17
Points : 6
Points : 6
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.
sabinaS est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 12h05.


 
 
 
 
Partenaires

Hébergement Web