Home Forums Share Code & Programming Solutions Error 97: cannot call friend function on object which is not an instance ..class

This topic contains 3 replies, has 2 voices, and was last updated by  Tom Crawford 1 year ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13739

    Robert2
    Premium Member

    The below code returns Run Time Error 97 – Can not call friend on object which is not an instance of defining class.

    Option Compare Database

    Public Static Sub QBCostCodeTest()
    Dim QBC As QBConnection
    Dim QBItem As qcItem
    Dim strString As String
    Set QBC = QBConnection
    ‘, “\\ramqb01\e$\RAM\EVG testing\Evergreene Companies Test.qbw”
    QBC.Connect “”, “MyAppName”, qbOpenModeDontCare, “”, “Q:\RAM\EVG Testing\MyQuickBooksDatabaseName.qbw”
    QBC.Company.Items.GetAll qbItemService
    Set QBItem = QBC.Company.Items(100)
    Debug.Print QBItem.Name
    Items.Rename QBItem, “1118 Eng – Driveways”
    QBC.CloseConnection
    End Sub

    #13798

    Make sure you commit the item after renaming it. Here is an example:

    Dim oI As qcItem

    QBConnection.Connect “”, APP_NAME, qbOpenModeDontCare, ACCESS_CODE

    Set oI = Items.GetByFullName(“Framing”)
    Items.Rename oI, “Framing New Name”
    Items.Commit oI

    #13825

    Robert2
    Premium Member

    I should have mentioned that:
    1. The error occurs on the line: Items.Rename QBItem, “1118 Eng – Driveways”, so Items.Commit will not even run.
    2. This exact same code works for renaming Venders and Customers, but errors on Items.

    #13849

    What version of the library do you have? You can download the latest from http://download.synergration.com/coreobjx70.zip

    Make sure you register them using REGSVR32.EXE

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.