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”
Set QBItem = QBC.Company.Items(100)
Items.Rename QBItem, “1118 Eng – Driveways”
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”
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.
You must be logged in to reply to this topic.