-
June 15th, 2009, 09:08 PM
#1
ChartSpace: Error 438 when double clicking the same portion
Hi all,
I am a newbie in using the third party helper (.ocx) and currently I am trying to use the ChartSpace to create a graph from the datagrid.
The data loads up and projected correctly inside the chart. Then I create a double click event for the chart. Following is the code that is used to check for the value inside the chart:
<code>
MsgBox Me.ChartSpace1.Selection.GetValue(chDimValues)
MsgBox Me.ChartSpace1.Selection.GetValue(chDimCategories)
</code>
This work if I double click that portion once. Means that after I double click and go to the result page, go back and never click the same portion again instead clicking on the other portion of the chart. But if I double click the same portion again, it prompts me with error 438: The object is not supported.
What is should I do to avoid the error to come up when the user double click on the same portion?
As I keep on looking on how to clear off the selection but I didn't get a clue about it.
Thank you in advance for all your help.
-ncuz-
-
June 15th, 2009, 11:45 PM
#2
Re: ChartSpace: Error 438 when double clicking the same portion
Ask the people that wrote the control. I've never heard of it
-
June 16th, 2009, 01:11 AM
#3
Re: ChartSpace: Error 438 when double clicking the same portion
Hi dglienna,
Thank you for your reply. I have send a mail back to the writer but I haven't got anything back yet.
When I check using the index, when I double click the first time it correctly grab the index. But when double click that again for the second time, it reset the index to 0 and prompts error. Yet when I double click on the other part it give me the correct index. I am still unable to solve this matter.
For the first I thought that I could use the index to trap the error. But then now I got another problem that it always stay on 0 instead of the correct index.
-
June 16th, 2009, 01:21 AM
#4
Re: ChartSpace: Error 438 when double clicking the same portion
Here's where they are trying to go, I'd guess:
Code:
If Me.CurrentView = acCurViewPivotTable Then
' Create some variables.
Dim sel As Object
Dim pivotagg As PivotAggregate
Dim sTotal As String
Dim sColMems As String
Dim sRowMems As String
Dim sFilters As String
Dim sMsg As String
' Get the selection.
Set sel = Me.PivotTable.Selection
' User could have clicked one of the following types of objects:
' PivotAggregates, PivotTotals, PivotMembers, PivotFields, etc.
' Use the TypeName() function to determine the object type.
MsgBox "The Selection property returned a '" & TypeName(sel) & "' object.", _
vbInformation, "Type of Selection Prop"
' If the type is PivotAggregates, show how to get the row
' and column member(s) that define that aggregate.
If TypeName(sel) = "PivotAggregates" Then
' PivotAggregates could contain many items, but because user could have
' double-clicked only a single item, it will contain just one item now,
' which will be item(0).
Set pivotagg = sel.Item(0)
' Show the value.
MsgBox "The cell you double-clicked has a value of '" & pivotagg.Value & _
"'.", vbInformation, "Value of Cell"
' Get the total name, row and column members, and the current filters.
sTotal = pivotagg.Total.Caption
sColMems = BuildFullName(pivotagg.Cell.ColumnMember)
sRowMems = BuildFullName(pivotagg.Cell.RowMember)
' Build the message and show it.
sMsg = "The value is " & sTotal & " by " & sRowMems & " by " & sColMems
If Len(sFilters) > 0 Then
sMsg = sMsg & " for " & Left(sFilters, Len(sFilters) - 2)
End If
MsgBox sMsg, vbInformation, "Value Info"
End If ' typename(sel) = "PivotAggregates"
End If ' Me.CurrentView = acCurViewPivotTable
http://office.microsoft.com/en-us/ac...345791033.aspx
-
June 16th, 2009, 01:40 AM
#5
Re: ChartSpace: Error 438 when double clicking the same portion
I get the code from this blog: http://blogs.msdn.com/access/archive...de-sample.aspx
Below is the code in which I read and get the code from:
Option Explicit
Private Const HandCursor = 32649&
Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Dim WithEvents oChart As ChartSpace
Private Sub Form_Load()
Set oChart = Me.ChartSpace
End Sub
Private Sub Form_Click()
Dim sVal As String
Dim sYear As String
Dim iSeperator As Integer
Select Case Me.ChartSpace.SelectionType
Case chSelectionPoint
sVal = Me.ChartSpace.Selection.GetValue(chDimCategories)
iSeperator = InStr(1, sVal, "-") 'make sure we only filter for year or month and year
If iSeperator = 0 Then 'selection is a year
FilterByYear sVal
ElseIf InStr(iSeperator + 1, sVal, "-") = 0 Then
'selection is a month and year
sYear = Trim$(Mid$(sVal, 1, iSeperator - 1))
sVal = Trim$(Mid$(sVal, iSeperator + 1))
FilterByMonth sYear, sVal
Else
Exit Sub 'selection is a day or somthing of a lower level that we don't filter for
End If
Case chSelectionCategoryLabel
'set the source object to the proper form
sVal = Me.ChartSpace.Selection.Caption
Select Case Me.ChartSpace.Selection.Level 'check to see what level was selected on the x axis
Case 0 'year
FilterByYear sVal
Case 1 'month
sYear = Me.ChartSpace.Selection.ParentLabel.Caption
FilterByMonth sYear, sVal
Case Else
Exit Sub 'selection is a day or somthing of a lower level that we don't filter for
End Select
End Select
End Sub
'filters the db list by month
Private Sub FilterByMonth(sYear As String, sVal As String)
Me.Parent.Form.Filter = BuildSQL(Trim$(sYear), Trim$(sVal))
Me.Parent.Form.FilterOn = True
End Sub
'filters the db list by year
Private Sub FilterByYear(sVal As String)
Me.Parent.Form.Filter = BuildSQL(Trim$(sVal), "")
If Me.Parent.Form.FilterOn = False Then Me.Parent.Form.FilterOn = True
End Sub
' builds the SQL that will filter the form
Private Function BuildSQL(sYear As String, sMonth As String) As String
Dim sFilterField As String
Dim sFilterControl As String
sFilterField = "[Est Closed Date]"
sFilterControl = "Est Closed Date"
If sMonth <> "" Then 'passed in year and month
BuildSQL = "(" & sFilterField & " >= #" & FormatDateTime(sMonth & " - " & sYear) & "#) AND (" & sFilterField & " <= #" & DateAdd("m", 1, FormatDateTime(sMonth & " - " & sYear)) - 1 & "#)"
Else 'just passed in the year
BuildSQL = "(" & sFilterField & " >= #1/1/" & sYear & "#) AND (" & sFilterField & " <= #12/31/" & sYear & "#)"
End If
'Clear the filter from the field the chart is filtered on.
'If you want to clear the entire filter, just set Me.Parent.Filter = "".
RemoveFilterFromField Me.Parent, sFilterControl
' If there is still something left of the filter
If Me.Parent.Filter <> "" Then
' Append
BuildSQL = BuildSQL & " AND (" & Me.Parent.Filter & ")"
End If
End Function
Private Sub RemoveFilterFromField(frm As Form, strControlName As String)
frm.SetFocus
frm.Controls(strControlName).SetFocus
On Error Resume Next
DoCmd.RunCommand acCmdRemoveFilterFromCurrentColumn ' This command is new to Access 2007.
Debug.Assert Err.Number = 0 Or Err.Number = 2046 ' 2046 is thrown when there was no filter on the column
Err.Clear
End Sub
Private Sub Form_CommandBeforeExecute(ByVal Command As Variant, ByVal Cancel As Object)
' Cancel the ability to drill into days and hours.
If Command = chCommandDrill Then
Cancel = True
End If
End Sub
Private Sub oChart_MouseMove(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)
Select Case TypeName(Me.ChartSpace.RangeFromPoint(x, y))
Case "ChCategoryLabel", "ChPoint"
'display hand cursor if pointer is over a label or bar
SetCursor LoadCursor(0, HandCursor)
Case Else
'display the normal cursor
Screen.MousePointer = 0
End Select
End Sub
Btw, how to put the code tag?
Thank you for your help.
-
June 16th, 2009, 09:20 PM
#6
Re: ChartSpace: Error 438 when double clicking the same portion
At the end I use the error catcher to get the error and do nothing when the user double click the same portion twice. This is only a temporary solution until I get to know how it works actually.
Because when I check the index using: Me.ChartSpace1.Selection.Index
It show me that when the user double click on it once, it get the correct index yet when the user double click it again it reset to 0 (but the index 0 has its own value yet it recognised as an error).
Anybody has any idea how can I do this?
Thank you.
-
June 16th, 2009, 09:46 PM
#7
Re: ChartSpace: Error 438 when double clicking the same portion
Try resetting the index after a double-click
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|