[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 710
  • Last Modified:

MSChart

The first time we assign a two dimensional array to a MsChat1 to generate a chart the RowLabels are Months & the COlumnLabels are Years
When we click on a command button to generate a chart, it works fine.  When we chlick the button a second time
 we get a run time error 1119 which says Object is uninitialized or invalid.  The program stops at the line where we are tyring to assign lables. i.e., "Mschart1.DataGrid.RowLabel(1,1) = "jan"  ...etc....
Thank you for your response to the same question, hope this is more specific. Would appreciate a response ASAP

Here's the code you asked for:

MSChart1 = CostArray 'CostArray is a 12 X 8 two-way array

If cmdShort = True Then
    MSChart1.Title = "SHORT TERM COST ANALYSIS"
ElseIf cmdLong = True Then
    MSChart1.Title = "Long TERM COST ANALYSIS"
ElseIf cmdVacation = True Then
    MSChart1.Title = "Vacation TERM COST ANALYSIS"
End If


MSChart1.DataGrid.RowLabel(1, 1) = " "
MSChart1.DataGrid.RowLabel(2, 1) = "jan"
MSChart1.DataGrid.RowLabel(3, 1) = "feb"
MSChart1.DataGrid.RowLabel(4, 1) = "mar"
MSChart1.DataGrid.RowLabel(5, 1) = "apr"
MSChart1.DataGrid.RowLabel(6, 1) = "may"
MSChart1.DataGrid.RowLabel(7, 1) = "jun"
MSChart1.DataGrid.RowLabel(8, 1) = "jul"
MSChart1.DataGrid.RowLabel(9, 1) = "aug"
MSChart1.DataGrid.RowLabel(10, 1) = "sept"
MSChart1.DataGrid.RowLabel(11, 1) = "oct"
MSChart1.DataGrid.RowLabel(12, 1) = "nov"
MSChart1.DataGrid.RowLabel(13, 1) = "dec"

MSChart1.DataGrid.ColumnLabel(1, 1) = 1996
MSChart1.DataGrid.ColumnLabel(2, 1) = 1997
MSChart1.DataGrid.ColumnLabel(3, 1) = 1998
MSChart1.DataGrid.ColumnLabel(4, 1) = 1999
MSChart1.DataGrid.ColumnLabel(5, 1) = 2000
MSChart1.DataGrid.ColumnLabel(6, 1) = 2001
MSChart1.DataGrid.ColumnLabel(7, 1) = 2002
MSChart1.DataGrid.ColumnLabel(8, 1) = 2003

MSChart1.Legend.Location.Visible = True

In other words how can we refresh the chart with new data?
At present when we try to do so we get an error
0
gitar
Asked:
gitar
  • 5
  • 2
  • 2
  • +2
1 Solution
 
bin_huwairibCommented:
gitar,

Post your code to figure out you problem.


Best regards
Bin Huwairib
0
 
zsiCommented:
gitar,

I'm sure that, by now, you are aware that you have posted the same question twice?
0
 
gitarAuthor Commented:
Edited text of question
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
gitarAuthor Commented:
Adjusted points to 70
0
 
gitarAuthor Commented:
Edited text of question
0
 
gitarAuthor Commented:
Adjusted points to 100
0
 
gitarAuthor Commented:
Adjusted points to 110
0
 
ducCommented:
What kind of error ?
Duc
0
 
ducCommented:
Sorry I just saw it.
Duc
0
 
clifABBCommented:
Apparently you can't redim a chart. (MSChart1 = CostArray can only be used once)
0
 
bin_huwairibCommented:
gitar,

Try the following code:

Private Sub Command1_Click()
 Dim CostArray(1 To 12, 1 To 8) As Integer
 Dim RowCount As Integer
 Dim ColumnCount As Integer

 RowCount = UBound(CostArray, 1)
 ColumnCount = UBound(CostArray, 2)
 MSChart1.RowCount = RowCount
 MSChart1.ColumnCount = ColumnCount
 For Row = 1 To RowCount
  For Column = 1 To ColumnCount
   MSChart1.Row = Row
   MSChart1.Column = Column
   MSChart1.Data = CostArray(Row, Column)
  Next
 Next
 
 If cmdShort = True Then
  MSChart1.Title = "SHORT TERM COST ANALYSIS"
 ElseIf cmdLong = True Then
  MSChart1.Title = "Long TERM COST ANALYSIS"
 ElseIf cmdVacation = True Then
  MSChart1.Title = "Vacation TERM COST ANALYSIS"
 End If
 
 MSChart1.DataGrid.RowLabel(1, 1) = "jan"
 MSChart1.DataGrid.RowLabel(2, 1) = "feb"
 MSChart1.DataGrid.RowLabel(3, 1) = "mar"
 MSChart1.DataGrid.RowLabel(4, 1) = "apr"
 MSChart1.DataGrid.RowLabel(5, 1) = "may"
 MSChart1.DataGrid.RowLabel(6, 1) = "jun"
 MSChart1.DataGrid.RowLabel(7, 1) = "jul"
 MSChart1.DataGrid.RowLabel(8, 1) = "aug"
 MSChart1.DataGrid.RowLabel(9, 1) = "sept"
 MSChart1.DataGrid.RowLabel(10, 1) = "oct"
 MSChart1.DataGrid.RowLabel(11, 1) = "nov"
 MSChart1.DataGrid.RowLabel(12, 1) = "dec"
 
 MSChart1.DataGrid.ColumnLabel(1, 1) = 1996
 MSChart1.DataGrid.ColumnLabel(2, 1) = 1997
 MSChart1.DataGrid.ColumnLabel(3, 1) = 1998
 MSChart1.DataGrid.ColumnLabel(4, 1) = 1999
 MSChart1.DataGrid.ColumnLabel(5, 1) = 2000
 MSChart1.DataGrid.ColumnLabel(6, 1) = 2001
 MSChart1.DataGrid.ColumnLabel(7, 1) = 2002
 MSChart1.DataGrid.ColumnLabel(8, 1) = 2003

 MSChart1.Legend.Location.Visible = True
End Sub


Best regards
Bin Huwairib
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 5
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now