Results 1 to 10 of 10

Thread: MS Chart frustraction - Resolved

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    58

    MS Chart frustraction - Resolved

    Hello
    I’ve been beating my head against the wall trying to get this MS Chart control to work with my VB 6 and Access 2k and ADO. It just shows the chart but with default values not what I have in my Access db. And, the recordset and connection object is not being created.

    I have my db set up like
    Year MS Sun Oracle Linux
    2000 100 200 300 450
    2001 200 250 325 500
    2002 150 350 425 375
    2003 225 400 325 500
    2004 275 500 425 475

    and code…
    Code:
    ‘ bas module
    Option Explicit
    Public cn As New ADODB.Connection
    Public rs As New ADODB.Recordset
    
    'Make Database Connection
    Public Sub main()
        Dim path As String
        path = App.path & "\myChart.mdb"
        cn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.00;data source=" & path & ";"
        cn.Open
        If cn.State = adStateClosed Then
            MsgBox "Connection Error", vbCritical, "Error!"
            End
        Else
            Debug.Print "Connection Object Created"
            cn.CursorLocation = adUseClient
        End If
        
        'Setting Initial data for recordset
        rs.Open "Select * from tblCategory", cn, adOpenDynamic, adLockOptimistic
        Debug.Print "Recordset Object Created"
        
        Call Form1.Show
    End Sub
    
    ‘ standard form
    Private Sub Form_Load()
        MSChart1.ShowLegend = True
        MSChart1.Title = "Companies Past Years Results"
        Set MSChart1.DataSource = rs
        MSChart1.Refresh
    End Sub
    kudos to anyone solving this

    Hal
    Last edited by KinkyWiz; Nov 20th, 2004 at 04:46 PM.

  2. #2
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457
    So are you saying that the Recordset is loading correctly, it is just the MSChart that is not responding?
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    58
    The recordset and connection objects are not appearing in the immediate window as they should with the code..
    Debug.Print "Connection Object Created"
    Debug.Print "Recordset Object Created"

    So I imagine that is much of the problem

    Steve

  4. #4
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457
    What do you get if you break on these two locations?
    VB Code:
    1. MsgBox "Connection Error", vbCritical, "Error!"  (HERE)
    2.         End
    3.     Else
    4.         Debug.Print "Connection Object Created"     (AND HERE)
    5.         cn.CursorLocation = adUseClient
    6.     End If
    One of them Must fire - but which one?
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    58
    I'm nearly embarrassed by my poor debugging skills. To put a break I click on the left panel to put a brown dot there? Then I just run the program?

    After i do that I don't see anything in the immediate window still but then I might not be doing this right

    Steve

  6. #6
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457
    That's correct Steve - hang on. Have you set the project to open the form on startup rather than run the main sub ??
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  7. #7
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457
    What should happen is that when the program runs it will stop on one of the two branches - that way you know where the code is going.

    If neither branch is running. I can only guess that you are jumping straight to Form 1. Skipping main altogether.
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  8. #8

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    58
    hahahahaha

    it works, wahoooooooooooooooooo

    yes, it was starting on form1 not the sub

    thankQ
    thankQ
    thankQ
    thankQ
    thankQ
    thankQ

    and ...

    thankQ

  9. #9
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457
    Good Oh. Ive learnt something as well then because I didn't know how to directly load an MSChart control from a recordset.



    Ok - Next step is to edit your original post and put a tick as the message Icon so that all and sundry know that the post has been resolved.

    Happy Coding.
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  10. #10

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    58
    Many thanks David
    Will do

    Good day!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width