Solved

MSChart

Posted on 1998-05-03
11
695 Views
Last Modified: 2008-02-01
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
Comment
Question by:gitar
  • 5
  • 2
  • 2
  • +2
11 Comments
 
LVL 5

Expert Comment

by:bin_huwairib
Comment Utility
gitar,

Post your code to figure out you problem.


Best regards
Bin Huwairib
0
 
LVL 4

Expert Comment

by:zsi
Comment Utility
gitar,

I'm sure that, by now, you are aware that you have posted the same question twice?
0
 

Author Comment

by:gitar
Comment Utility
Edited text of question
0
 

Author Comment

by:gitar
Comment Utility
Adjusted points to 70
0
 

Author Comment

by:gitar
Comment Utility
Edited text of question
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:gitar
Comment Utility
Adjusted points to 100
0
 

Author Comment

by:gitar
Comment Utility
Adjusted points to 110
0
 

Expert Comment

by:duc
Comment Utility
What kind of error ?
Duc
0
 

Expert Comment

by:duc
Comment Utility
Sorry I just saw it.
Duc
0
 
LVL 6

Accepted Solution

by:
clifABB earned 110 total points
Comment Utility
Apparently you can't redim a chart. (MSChart1 = CostArray can only be used once)
0
 
LVL 5

Expert Comment

by:bin_huwairib
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now