Create Sales Order Lines Object from MS Access Module


Good Day,

I hope this message finds you well. I am currently facing an issue with a control I've created in MS Access that interacts with Sage100 (Standard 2020 v6.20.4). I'm reaching out to seek your assistance in resolving this matter.

The control performs the following actions:

  1. Logs into Sage100.
  2. Locates and sets the Sales Order, updating the UDF_SMI_Release value on the sales order header.
  3. Iterates through the lines of the Sales Order and updates the UDF_PMQTY value.
  4. write the line record.
  5. write the header record

However, I've encountered a problem. Despite receiving successful return values for edtLne (2), getVal (1), and setVal (1), the write line returns an error stating, "File does not exist: File: RA_Options." When I suppress the write line the header write preforms as expected but the values in the lines section of the Sales Order do not update.

I want to highlight that the Sage version I'm currently testing on has Scanco's PM and Multi-bin installed. Although these enhancements have caused interference with the User Interface (UI) and Business Object Interface (BOI) in the past, I am unsure if they are the cause of this particular issue.

I've included snippets of the associated code and a screenshot of the relevant access screen below:

I would greatly appreciate your expertise and guidance in resolving this issue. If there is any additional information or details you require, please let me know.

Best Regards,


Pasted code snippets: Access screenshot below:

setVal = oSOHdr.nSetKeyValue( "SalesOrderNo$", sSONo )
setKey = oSOHdr.nSetKey()
setVal = oSOHdr.nSetValue( "UDF_SMI_RELEASE$", bSMI )
MsgBox( IsObject( oSOHdr.oLines ) )
'movVal = oSOHdr.oLines.MoveFirst() '< Error line is commented
'Do While Not cBool( oSOHdr.oLines ) '< Error line is commented
edtLne = oSOHdr.oLines.nEditline( sLineKey ) return  value = 2
If edtLne = 0 Then : MsgBox("ERROR edit line method " & oSS.sLastErrorMsg) : Else MsgBox("Edit Line " & edtLne & ":"& sLineKey & " method Good") '< debug only
getVal = oSOHdr.oLines.nGetValue( "ItemCode$", sItemCode ) return value = 1
If getVal = 0 Then : MsgBox("ERROR Get value " & oSS.sLastErrorMsg) : Else MsgBox("Get Item " & getVal & ":" & sItemCode & " value Good") '< debug only
setVal = oSOHdr.oLines.nSetValue( "UDF_PMQTY", nPMQty ) return value = 1
If setVal = 0 Then : MsgBox("ERROR Set value " & oSS.sLastErrorMsg) : Else MsgBox("Set " & setVal & ":" & nPMQty & " Value method Good") '<debug only
wrtVal = oSOHdr.oLines.nWrite() '<Error #12
If wrtVal = 0 Then : MsgBox("Line Write ERROR > " & oSS.sLastErrorMsg) : Else MsgBox("Line wrtVal SO " & wrtVal & ":" & sSONo & sLineKey & " Good") '< debug only
'movVal = oSOHdr.oLines.MoveNext() '< Error
'Loop '<Error
wrtVal = oSOHdr.nWrite()
If wrtVal = 0 Then : MsgBox("ERROR wrtVal " & oSS.sLastErrorMsg) : Else MsgBox("wrtVal SONo " & sSONo & " Good") '< debug only
End If

Parents Reply
  • 0 in reply to SKG HIBARS


    The Steve you are "correcting" is one of the lead Sage 100 programmers, and knows his stuff very well.

    I've used line loops with MoveNext, SetValue, Write, MoveNext... many times, and SetKey is not required for each line.  The header has to be in an editable state when you create your line object though.

  • 0 in reply to Kevin M


    While I don't consider myself an expert, I want to clarify that I never stated it was necessary for "each" line. Instead, you can execute the SetKey on the header to gain access to the lines object. From there, you can loop through and make edits as needed. However, regardless of this approach, I would appreciate an explanation as to why I am receiving the return values mentioned above. 

    See reply to BilLouie