Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Credit from OE Errors

Status
Not open for further replies.

badmotorvision

Programmer
Oct 15, 2009
22
US
I am trying to create a credit from an invoice and not
having any luck. I get a read-only error on
OECRD1detail1Fields.FieldByName("QTYRETURN").Value = line.dec_RTN_Qty

Here is the generated vba script. Im doing the same thing in my vb.net code but it blows on the qtyreturn.
If I run the exact same script from accpac it works.


Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)

Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkSysRW = OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)

Dim temp As Boolean
Dim OECRD1header As AccpacCOMAPI.AccpacView
Dim OECRD1headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0240", OECRD1header
Set OECRD1headerFields = OECRD1header.Fields

Dim OECRD1detail1 As AccpacCOMAPI.AccpacView
Dim OECRD1detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0220", OECRD1detail1
Set OECRD1detail1Fields = OECRD1detail1.Fields

Dim OECRD1detail2 As AccpacCOMAPI.AccpacView
Dim OECRD1detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0640", OECRD1detail2
Set OECRD1detail2Fields = OECRD1detail2.Fields

Dim OECRD1detail3 As AccpacCOMAPI.AccpacView
Dim OECRD1detail3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0140", OECRD1detail3
Set OECRD1detail3Fields = OECRD1detail3.Fields

Dim OECRD1detail4 As AccpacCOMAPI.AccpacView
Dim OECRD1detail4Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0242", OECRD1detail4
Set OECRD1detail4Fields = OECRD1detail4.Fields

Dim OECRD1detail5 As AccpacCOMAPI.AccpacView
Dim OECRD1detail5Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0221", OECRD1detail5
Set OECRD1detail5Fields = OECRD1detail5.Fields

Dim OECRD1detail6 As AccpacCOMAPI.AccpacView
Dim OECRD1detail6Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0222", OECRD1detail6
Set OECRD1detail6Fields = OECRD1detail6.Fields

Dim OECRD1detail7 As AccpacCOMAPI.AccpacView
Dim OECRD1detail7Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0224", OECRD1detail7
Set OECRD1detail7Fields = OECRD1detail7.Fields

Dim OECRD1detail8 As AccpacCOMAPI.AccpacView
Dim OECRD1detail8Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0223", OECRD1detail8
Set OECRD1detail8Fields = OECRD1detail8.Fields

OECRD1header.Compose Array(OECRD1detail1, OECRD1detail2, OECRD1detail3, OECRD1detail4)

OECRD1detail1.Compose Array(OECRD1header, OECRD1detail5, OECRD1detail8, OECRD1detail6)

OECRD1detail2.Compose Array(OECRD1header)

OECRD1detail3.Compose Array(OECRD1header)

OECRD1detail4.Compose Array(OECRD1header)

OECRD1detail5.Compose Array(OECRD1detail1)

OECRD1detail6.Compose Array(OECRD1detail1, OECRD1detail7)

OECRD1detail7.Compose Array(OECRD1detail6)

OECRD1detail8.Compose Array(OECRD1detail1)



OECRD1headerFields("DRIVENBYUI").Value = "1" ' Driven by UI

OECRD1detail1Fields("DRIVENBYUI").Value = "1" ' Driven by UI
OECRD1header.Cancel
temp = OECRD1header.Exists
OECRD1header.Init
OECRD1header.Cancel
temp = OECRD1header.Exists
OECRD1header.Init
temp = OECRD1header.Exists
temp = OECRD1header.Exists
temp = OECRD1header.Exists

OECRD1headerFields("CUSTOMER").Value = "104" ' Customer Number

temp = OECRD1header.Exists
temp = OECRD1header.Exists
temp = OECRD1header.Exists
temp = OECRD1header.Exists
temp = OECRD1header.Exists
temp = OECRD1header.Exists
temp = OECRD1header.Exists
temp = OECRD1header.Exists
OECRD1header.Cancel
temp = OECRD1header.Exists
OECRD1header.Init

OECRD1headerFields("INVNUMBER").Value = "INV005082" ' Invoice Number
temp = OECRD1header.Exists
temp = OECRD1header.Exists
OECRD1detail1Fields("LINENUM").PutWithoutVerification ("-1") ' Line Number
OECRD1detail1.Read

OECRD1detail1Fields("QTYRETURN").Value = "5.0000" ' Quantity Returned

OECRD1detail1.Update

OECRD1detail1Fields("LINENUM").PutWithoutVerification ("-1") ' Line Number

OECRD1detail1.Read
temp = OECRD1header.Exists

OECRD1headerFields("OECOMMAND").PutWithoutVerification ("4") ' Process Command

OECRD1header.Process
OECRD1header.Insert
OECRD1header.Read

 
Credit/Debit Detail Attempt to change read-only field 'Quantity Returned'
is the actual error i receive
 
What version of accpac are you using and what is the value of line.dec_RTN_Qty?

Also just to clean up the macro a bit, you do not really need any of the 'temp' lines.

If at first you don't succeed, then sky diving wasn't meant for you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top