Results 1 to 5 of 5

Thread: [RESOLVED] MSCHRT20.OCX in Windows 11

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2022
    Posts
    76

    Resolved [RESOLVED] MSCHRT20.OCX in Windows 11

    This is really a VBA question as I have never used MSCHRT20.OCX in VB6 before, but used it a LOT in VBA, under Access in Office 2016, and earlier. I do believe MSCHRT20.OCX is a VB6 SP6 component?

    It works fine in forms, but I can not seem to use it in reports. When I try to put data in it's spreadsheet, I get errors. The EXACT SAME VBA program and REPORT running under Windows 7 works perfect. The new error is telling be that I can not change the value of the data in the chart. Here is a snipet:

    ' ==================================================================
    ' Horz Linearity Chart
    ' ==================================================================
    Set Graph_Data = Me.HorzLinChart.Object
    Set objDataSheet = Graph_Data.Application.datasheet
    Set objAxis = Graph_Data.Axes(2)
    '
    HorzDevAdj = ((rs.Fields("TOF9") - 450) - (rs.Fields("TOF3") - 150)) / 5
    '
    objDataSheet.Range("A1").Value = rs.Fields("TOF1") <- an example of the data in this field would be 49.9

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    This line creates an error.

    Name:  Chart Error.jpg
Views: 121
Size:  12.6 KB

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,809

    Re: MSCHRT20.OCX in Windows 11

    Perhaps you are using some other MS Office control.

    MSChart (MSCHRT20.OCX) has no "Application" or "datasheet" or "Range" anywhere in its object model.

  3. #3
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,254

    Re: MSCHRT20.OCX in Windows 11

    I cannot understand, why one would consider an old and limited chart.ocx,
    whilst already sitting on top of one of the most powerful charting-object-models ever build (Excel).

    Excel-charting-objects have an export-method (to *.jpg, *.png, *.emf) -
    so the final visualizing in a Userforms Image-Control should not be a problem.

    Olaf

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2022
    Posts
    76

    Re: MSCHRT20.OCX in Windows 11

    Well, the instrument test program is written in Access VBA, not Excel. Now if you can link the two, I have no experience with that.

    What I found was that I had to change the objDataSheet.Range("A1").Value = rs.Fields("TOF1") to: objDataSheet.Range("A1").Value = str(rs.Fields("TOF1")) and it worked perfect.

    Under Access 2016 in Windows 7, it worked fine without the str function. Maybe it should have been that way all along. Funny thing is on another page of the report, it populates a chart's sheet the same way without the STR function and without error. This is just a weird fluke, I guess, but I did get it working. On the computer it creates the 20+ page report a lot quicker than under Windows 7.

    If there is any articles you know of that show how to use an Excel chart in an Access report, I sure would love to study how to do it. For now, that old chart.ocx works fine for me.

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    8,430

    Re: [RESOLVED] MSCHRT20.OCX in Windows 11

    I do all my work in VB6 (not the VBA), but I know that you can "automate" Excel from either VB6 or from any VBA code. When I do it from VB6, I load Excel, make sure it's invisible, do my work, export whatever file I want, and then shut it down. The user never even knows Excel was loaded.

    I do this to make all kinds of graphs and figures. And yeah, you can export them as images, and then suck them up into whatever you want for display.

    Automation isn't trivial, but the macro recorders do help tremendously.

    And yeah, if you've got MS-Access, you almost certainly also have MS-Excel.

    But yeah, it would require some rewriting of things.

    ------------------------

    You also mention showing an Excel chart in an Access report. You can do that as well, just embed (or link) it into it. That's yet another option.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

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