?
Solved

MSChart

Posted on 1998-05-03
11
Medium Priority
?
705 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +2
11 Comments
 
LVL 5

Expert Comment

by:bin_huwairib
ID: 1437640
gitar,

Post your code to figure out you problem.


Best regards
Bin Huwairib
0
 
LVL 4

Expert Comment

by:zsi
ID: 1437641
gitar,

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

Author Comment

by:gitar
ID: 1437642
Edited text of question
0
Independent Software Vendors: 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!

 

Author Comment

by:gitar
ID: 1437643
Adjusted points to 70
0
 

Author Comment

by:gitar
ID: 1437644
Edited text of question
0
 

Author Comment

by:gitar
ID: 1437645
Adjusted points to 100
0
 

Author Comment

by:gitar
ID: 1437646
Adjusted points to 110
0
 

Expert Comment

by:duc
ID: 1437647
What kind of error ?
Duc
0
 

Expert Comment

by:duc
ID: 1437648
Sorry I just saw it.
Duc
0
 
LVL 6

Accepted Solution

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

Expert Comment

by:bin_huwairib
ID: 1437650
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

752 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