Solved

MSChart

Posted on 1998-05-03
11
696 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
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
 

Author Comment

by:gitar
ID: 1437643
Adjusted points to 70
0
 

Author Comment

by:gitar
ID: 1437644
Edited text of question
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 110 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

895 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

17 Experts available now in Live!

Get 1:1 Help Now