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:Merci d'avance
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
Partager