Hi Everyone,
I'm trying to post PO Receipts from MS Access. I've created the macro and modified the code to suit my application, but receive an AUTOMATION ERROR. UNSPECIFIED ERROR the minute I access the detail. I am also trying to be "clever" and print the report in the same go, but receive an error SESSION NOT OPEN, even if I include the same method to open the module at the beginning, infront of the print/preview portion. (I know that there might be garbage, but I'm not to sure what exactly is considered as garbage code)
Thanks in advance!
CODE:
Option Compare Database
Option Explicit
Public Function Receipt()
Dim MyDb As Database, MySet As Recordset, MySql As String, MyDocNum As String, MyCnt As Integer, MySeq, MyRef As String
MySql = "select * from dbo_DelNotes where dbo_DelNotes.PROCESSED = 0"
MyCnt = DCount("PONUMBER", "dbo_DelNotes", "PROCESSED = 0")
If MyCnt = 0 Then Exit Function
Set MyDb = CurrentDb
Set MySet = MyDb.OpenRecordset(MySql, dbOpenDynaset, dbSeeChanges)
On Error GoTo ACCPACErrorHandler
OpenMyModule "PO", "PO1310" 'Re-direct to Custom module
'USE: "??", "??xxxx"
'?? = Module abreviation (AP,AR,CB,IC,OE,PO etc.)
'xxxx = Related Module Accpac view
'Ex: OpenMyModule "PO", "PO1310"
On Error GoTo ACCPACErrorHandler
Dim temp As Boolean
Dim PORCP1header As AccpacCOMAPI.AccpacView
Dim PORCP1headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0700", PORCP1header
Set PORCP1headerFields = PORCP1header.Fields
Dim PORCP1detail1 As AccpacCOMAPI.AccpacView
Dim PORCP1detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0710", PORCP1detail1
Set PORCP1detail1Fields = PORCP1detail1.Fields
Dim PORCP1detail2 As AccpacCOMAPI.AccpacView
Dim PORCP1detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0695", PORCP1detail2
Set PORCP1detail2Fields = PORCP1detail2.Fields
Dim PORCP1detail3 As AccpacCOMAPI.AccpacView
Dim PORCP1detail3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0718", PORCP1detail3
Set PORCP1detail3Fields = PORCP1detail3.Fields
Dim PORCP1detail4 As AccpacCOMAPI.AccpacView
Dim PORCP1detail4Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0714", PORCP1detail4
Set PORCP1detail4Fields = PORCP1detail4.Fields
Dim PORCP1detail5 As AccpacCOMAPI.AccpacView
Dim PORCP1detail5Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0699", PORCP1detail5
Set PORCP1detail5Fields = PORCP1detail5.Fields
Dim PORCP1detail6 As AccpacCOMAPI.AccpacView
Dim PORCP1detail6Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0705", PORCP1detail6
Set PORCP1detail6Fields = PORCP1detail6.Fields
Dim PORCP1detail7 As AccpacCOMAPI.AccpacView
Dim PORCP1detail7Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0703", PORCP1detail7
Set PORCP1detail7Fields = PORCP1detail7.Fields
Dim PORCP1detail8 As AccpacCOMAPI.AccpacView
Dim PORCP1detail8Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0696", PORCP1detail8
Set PORCP1detail8Fields = PORCP1detail8.Fields
Dim PORCP1detail9 As AccpacCOMAPI.AccpacView
Dim PORCP1detail9Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0717", PORCP1detail9
Set PORCP1detail9Fields = PORCP1detail9.Fields
Dim PORCP1detail10 As AccpacCOMAPI.AccpacView
Dim PORCP1detail10Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0721", PORCP1detail10
Set PORCP1detail10Fields = PORCP1detail10.Fields
Dim PORCP1detail11 As AccpacCOMAPI.AccpacView
Dim PORCP1detail11Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0719", PORCP1detail11
Set PORCP1detail11Fields = PORCP1detail11.Fields
Dim PORCP1detail12 As AccpacCOMAPI.AccpacView
Dim PORCP1detail12Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0697", PORCP1detail12
Set PORCP1detail12Fields = PORCP1detail12.Fields
Dim PORCP1detail13 As AccpacCOMAPI.AccpacView
Dim PORCP1detail13Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0704", PORCP1detail13
Set PORCP1detail13Fields = PORCP1detail13.Fields
PORCP1header.Compose Array(PORCP1detail2, PORCP1detail1, PORCP1detail3, PORCP1detail4, PORCP1detail5, PORCP1detail6, PORCP1detail7, PORCP1detail8)
PORCP1detail1.Compose Array(PORCP1header, PORCP1detail2, PORCP1detail5, Nothing, Nothing, PORCP1detail9)
PORCP1detail2.Compose Array(PORCP1header, PORCP1detail1)
PORCP1detail3.Compose Array(PORCP1header, PORCP1detail4, PORCP1detail5, PORCP1detail10)
PORCP1detail4.Compose Array(PORCP1detail3, PORCP1detail5, PORCP1header, Nothing, Nothing, PORCP1detail11, PORCP1detail8)
PORCP1detail5.Compose Array(PORCP1header, PORCP1detail2, PORCP1detail1, PORCP1detail4, PORCP1detail3, PORCP1detail6, PORCP1detail8)
PORCP1detail6.Compose Array(PORCP1header, PORCP1detail5)
PORCP1detail7.Compose Array(PORCP1header)
PORCP1detail8.Compose Array(PORCP1detail4, PORCP1detail3, PORCP1header, PORCP1detail5, PORCP1detail12)
PORCP1detail9.Compose Array(PORCP1detail1)
PORCP1detail10.Compose Array(PORCP1detail3)
PORCP1detail11.Compose Array(PORCP1detail4)
PORCP1detail12.Compose Array(Nothing, PORCP1detail8, PORCP1detail4)
PORCP1detail13.Compose Array(PORCP1detail8, PORCP1detail1)
MySet.MoveFirst
Do While Not MySet.EOF
PORCP1header.Order = 1
PORCP1header.Order = 0
PORCP1headerFields("RCPHSEQ").PutWithoutVerification ("0") ' Receipt Sequence Key
temp = PORCP1header.Exists
PORCP1header.Init
PORCP1header.Order = 1
temp = PORCP1detail1.Exists
PORCP1detail1.RecordClear
temp = PORCP1detail3.Exists
PORCP1detail3.RecordClear
temp = PORCP1detail4.Exists
PORCP1detail4.RecordClear
temp = PORCP1detail6.Exists
PORCP1detail6.Init
temp = PORCP1detail2.Exists
PORCP1detail2.Init
PORCP1headerFields("VDCODE").Value = MySet!VDCODE ' Vendor
PORCP1headerFields("PROCESSCMD").PutWithoutVerification ("1") ' Command
PORCP1header.Process
PORCP1headerFields("PONUMBER").Value = MySet!PONUMBER ' Purchase Order Number
MySeq = PORCP1headerFields("RCPHSEQ").Value ' Obtain Receipt Sequence Key
PORCP1header.Order = 0
'ERROR 1
PORCP1detail5Fields("LOADPORNUM").Value = MySet!PONUMBER ' Purchase Order Number
PORCP1detail5Fields("FUNCTION").PutWithoutVerification ("4") ' Function
'ERROR 1
PORCP1detail5.Process
PORCP1header.Order = 1
PORCP1detail3Fields("PROCESSCMD").PutWithoutVerification ("1") ' Command
PORCP1detail3.Process
PORCP1headerFields("DATE").Value = MySet!DELDATE ' Receipt Date
PORCP1detail5Fields("FUNCTION").Value = "61" ' Function
PORCP1detail5.Process
PORCP1headerFields("STCODE").Value = MySet!LOCATION ' Ship-To Location
PORCP1headerFields("DESCRIPTIO").Value = "Del. Note: " & MySet!DELNOTENUM & " - Truck Reg.: " & MySet!TRUCKREG ' Description
PORCP1headerFields("REFERENCE").Value = MySet!INTREQNO ' Reference
PORCP1detail1Fields("RCPLREV").PutWithoutVerification ("-1") ' Line Number
PORCP1detail1Fields("RCPLREV").PutWithoutVerification ("-1") ' Line Number
PORCP1detail1.Read
temp = PORCP1detail1.Exists
temp = PORCP1detail1.Exists
'ERROR
PORCP1detail1Fields("LOCATION").Value = MySet!LOCATION ' Location
temp = PORCP1detail1.Exists
'ERROR
PORCP1detail1Fields("RQRECEIVED").Value = MySet!DELQTY ' Quantity Received
If MySet!DELQTY >= PORCP1detail1Fields("OQORDERED").Value Then
PORCP1detail1Fields("POCOMPLETE").Value = "-1" ' Completes PO
ElseIf (MySet!DELQTY - PORCP1detail1Fields("RQRECEIVED").Value) / PORCP1detail1Fields("OQORDERED").Value = 0.02 Then
PORCP1detail1Fields("POCOMPLETE").Value = "-1" ' Completes PO and Cancel Remainder
PORCP1detail1Fields("RQCANCELED").Value = MySet!DELQTY - PORCP1detail1Fields("RQRECEIVED").Value ' Quantity Canceled
Else
PORCP1detail1Fields("POCOMPLETE").Value = "-1" ' Completes PO - NO
End If
temp = PORCP1detail1.Exists
PORCP1detail1.Update
PORCP1detail1Fields("RCPLREV").PutWithoutVerification ("-1") ' Line Number
'ERROR
PORCP1detail1.Read
PORCP1detail3.Browse "(RCPHSEQ = " & MySeq & ")", 1
temp = PORCP1detail3.Exists
PORCP1detail3.RecordClear
PORCP1detail5Fields("FUNCTION").PutWithoutVerification ("10") ' Function
PORCP1detail5.Process
temp = PORCP1header.Exists
PORCP1header.Insert
MyDocNum = PORCP1headerFields("RCPNUMBER").Value ' Read Receipt number
PORCP1detail5Fields("RCPHSEQ").PutWithoutVerification (MySeq) ' Receipt Sequence Key
PORCP1detail5Fields("FUNCTION").PutWithoutVerification ("2") ' Function
'Update processed lines
DoCmd.SetWarnings False
DoCmd.RunSQL "Update dbo_DelNotes SET dbo_DelNotes.PROCESSED = -1, dbo_DelNotes.PROCDATE = #" & Format(Now(), "yyyy/MM/dd HH:mm:ss") & "#, dbo_DelNotes.RCPTNUM ='" & MyDocNum & "' where dbo_DelNotes.UnqID = " & MySet!UnqID
DoCmd.SetWarnings True
PORCP1detail5.Process
Dim POPRNT2 As AccpacCOMAPI.AccpacView
Dim POPRNT2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0640", POPRNT2
Set POPRNT2Fields = POPRNT2.Fields
Dim rpt As AccpacCOMAPI.AccpacReport
'ERROR AFTER EVERY COMMAND IN THIS SECTION
Set rpt = ReportSelect("PORCP01[PORCP01.RPT]", " ", " ")
Dim rptPrintSetup As AccpacCOMAPI.AccpacPrintSetup
Set rptPrintSetup = GetPrintSetup(" ", " ")
rptPrintSetup.DeviceName = "Feeds_copy&print_general"
rptPrintSetup.OutputName = "10.10.5.233"
rptPrintSetup.Orientation = 1
rptPrintSetup.PaperSize = 1
rptPrintSetup.PaperSource = 15
rpt.PrinterSetup rptPrintSetup
rpt.SetParam "RCPFROM", MyDocNum ' Report parameter: 2
rpt.SetParam "RCPTO", MyDocNum ' Report parameter: 3
rpt.SetParam "PRINTED", "1" ' Report parameter: 4
rpt.SetParam "QTYDEC", "4" ' Report parameter: 5
rpt.NumOfCopies = 1
rpt.Destination = PD_PREVIEW
rpt.PrintDir = ""
rpt.PrintReport
temp = POPRNT2.Exists
POPRNT2.Init
POPRNT2Fields("DOCTYPE").PutWithoutVerification ("3") ' Document Type
POPRNT2Fields("FROMRCP").PutWithoutVerification (MyDocNum) ' From Receipt Number
POPRNT2Fields("TORCP").PutWithoutVerification (MyDocNum) ' To Receipt Number
POPRNT2.Process
temp = PORCP1header.Exists
PORCP1header.Init
PORCP1header.Order = 0
PORCP1headerFields("RCPHSEQ").PutWithoutVerification ("0") ' Receipt Sequence Key
temp = PORCP1header.Exists
PORCP1header.Init
PORCP1header.Order = 1
temp = PORCP1detail1.Exists
PORCP1detail1.RecordClear
temp = PORCP1detail3.Exists
PORCP1detail3.RecordClear
temp = PORCP1detail4.Exists
PORCP1detail4.RecordClear
temp = PORCP1detail6.Exists
PORCP1detail6.Init
temp = PORCP1detail2.Exists
PORCP1detail2.Init
MySet.MoveNext
Loop
MySet.Close
Exit Function
ACCPACErrorHandler:
Dim lCount As Long
Dim lIndex As Long
If Errors Is Nothing Then
MsgBox Err.Description
Else
lCount = Errors.Count
If lCount = 0 Then
MsgBox Err.Description
Else
For lIndex = 0 To lCount - 1
MsgBox Errors.Item(lIndex)
Next
Err.Clear
End If
Resume Next
End If
End Function
I'm trying to post PO Receipts from MS Access. I've created the macro and modified the code to suit my application, but receive an AUTOMATION ERROR. UNSPECIFIED ERROR the minute I access the detail. I am also trying to be "clever" and print the report in the same go, but receive an error SESSION NOT OPEN, even if I include the same method to open the module at the beginning, infront of the print/preview portion. (I know that there might be garbage, but I'm not to sure what exactly is considered as garbage code)
Thanks in advance!
CODE:
Option Compare Database
Option Explicit
Public Function Receipt()
Dim MyDb As Database, MySet As Recordset, MySql As String, MyDocNum As String, MyCnt As Integer, MySeq, MyRef As String
MySql = "select * from dbo_DelNotes where dbo_DelNotes.PROCESSED = 0"
MyCnt = DCount("PONUMBER", "dbo_DelNotes", "PROCESSED = 0")
If MyCnt = 0 Then Exit Function
Set MyDb = CurrentDb
Set MySet = MyDb.OpenRecordset(MySql, dbOpenDynaset, dbSeeChanges)
On Error GoTo ACCPACErrorHandler
OpenMyModule "PO", "PO1310" 'Re-direct to Custom module
'USE: "??", "??xxxx"
'?? = Module abreviation (AP,AR,CB,IC,OE,PO etc.)
'xxxx = Related Module Accpac view
'Ex: OpenMyModule "PO", "PO1310"
On Error GoTo ACCPACErrorHandler
Dim temp As Boolean
Dim PORCP1header As AccpacCOMAPI.AccpacView
Dim PORCP1headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0700", PORCP1header
Set PORCP1headerFields = PORCP1header.Fields
Dim PORCP1detail1 As AccpacCOMAPI.AccpacView
Dim PORCP1detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0710", PORCP1detail1
Set PORCP1detail1Fields = PORCP1detail1.Fields
Dim PORCP1detail2 As AccpacCOMAPI.AccpacView
Dim PORCP1detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0695", PORCP1detail2
Set PORCP1detail2Fields = PORCP1detail2.Fields
Dim PORCP1detail3 As AccpacCOMAPI.AccpacView
Dim PORCP1detail3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0718", PORCP1detail3
Set PORCP1detail3Fields = PORCP1detail3.Fields
Dim PORCP1detail4 As AccpacCOMAPI.AccpacView
Dim PORCP1detail4Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0714", PORCP1detail4
Set PORCP1detail4Fields = PORCP1detail4.Fields
Dim PORCP1detail5 As AccpacCOMAPI.AccpacView
Dim PORCP1detail5Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0699", PORCP1detail5
Set PORCP1detail5Fields = PORCP1detail5.Fields
Dim PORCP1detail6 As AccpacCOMAPI.AccpacView
Dim PORCP1detail6Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0705", PORCP1detail6
Set PORCP1detail6Fields = PORCP1detail6.Fields
Dim PORCP1detail7 As AccpacCOMAPI.AccpacView
Dim PORCP1detail7Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0703", PORCP1detail7
Set PORCP1detail7Fields = PORCP1detail7.Fields
Dim PORCP1detail8 As AccpacCOMAPI.AccpacView
Dim PORCP1detail8Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0696", PORCP1detail8
Set PORCP1detail8Fields = PORCP1detail8.Fields
Dim PORCP1detail9 As AccpacCOMAPI.AccpacView
Dim PORCP1detail9Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0717", PORCP1detail9
Set PORCP1detail9Fields = PORCP1detail9.Fields
Dim PORCP1detail10 As AccpacCOMAPI.AccpacView
Dim PORCP1detail10Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0721", PORCP1detail10
Set PORCP1detail10Fields = PORCP1detail10.Fields
Dim PORCP1detail11 As AccpacCOMAPI.AccpacView
Dim PORCP1detail11Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0719", PORCP1detail11
Set PORCP1detail11Fields = PORCP1detail11.Fields
Dim PORCP1detail12 As AccpacCOMAPI.AccpacView
Dim PORCP1detail12Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0697", PORCP1detail12
Set PORCP1detail12Fields = PORCP1detail12.Fields
Dim PORCP1detail13 As AccpacCOMAPI.AccpacView
Dim PORCP1detail13Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0704", PORCP1detail13
Set PORCP1detail13Fields = PORCP1detail13.Fields
PORCP1header.Compose Array(PORCP1detail2, PORCP1detail1, PORCP1detail3, PORCP1detail4, PORCP1detail5, PORCP1detail6, PORCP1detail7, PORCP1detail8)
PORCP1detail1.Compose Array(PORCP1header, PORCP1detail2, PORCP1detail5, Nothing, Nothing, PORCP1detail9)
PORCP1detail2.Compose Array(PORCP1header, PORCP1detail1)
PORCP1detail3.Compose Array(PORCP1header, PORCP1detail4, PORCP1detail5, PORCP1detail10)
PORCP1detail4.Compose Array(PORCP1detail3, PORCP1detail5, PORCP1header, Nothing, Nothing, PORCP1detail11, PORCP1detail8)
PORCP1detail5.Compose Array(PORCP1header, PORCP1detail2, PORCP1detail1, PORCP1detail4, PORCP1detail3, PORCP1detail6, PORCP1detail8)
PORCP1detail6.Compose Array(PORCP1header, PORCP1detail5)
PORCP1detail7.Compose Array(PORCP1header)
PORCP1detail8.Compose Array(PORCP1detail4, PORCP1detail3, PORCP1header, PORCP1detail5, PORCP1detail12)
PORCP1detail9.Compose Array(PORCP1detail1)
PORCP1detail10.Compose Array(PORCP1detail3)
PORCP1detail11.Compose Array(PORCP1detail4)
PORCP1detail12.Compose Array(Nothing, PORCP1detail8, PORCP1detail4)
PORCP1detail13.Compose Array(PORCP1detail8, PORCP1detail1)
MySet.MoveFirst
Do While Not MySet.EOF
PORCP1header.Order = 1
PORCP1header.Order = 0
PORCP1headerFields("RCPHSEQ").PutWithoutVerification ("0") ' Receipt Sequence Key
temp = PORCP1header.Exists
PORCP1header.Init
PORCP1header.Order = 1
temp = PORCP1detail1.Exists
PORCP1detail1.RecordClear
temp = PORCP1detail3.Exists
PORCP1detail3.RecordClear
temp = PORCP1detail4.Exists
PORCP1detail4.RecordClear
temp = PORCP1detail6.Exists
PORCP1detail6.Init
temp = PORCP1detail2.Exists
PORCP1detail2.Init
PORCP1headerFields("VDCODE").Value = MySet!VDCODE ' Vendor
PORCP1headerFields("PROCESSCMD").PutWithoutVerification ("1") ' Command
PORCP1header.Process
PORCP1headerFields("PONUMBER").Value = MySet!PONUMBER ' Purchase Order Number
MySeq = PORCP1headerFields("RCPHSEQ").Value ' Obtain Receipt Sequence Key
PORCP1header.Order = 0
'ERROR 1
PORCP1detail5Fields("LOADPORNUM").Value = MySet!PONUMBER ' Purchase Order Number
PORCP1detail5Fields("FUNCTION").PutWithoutVerification ("4") ' Function
'ERROR 1
PORCP1detail5.Process
PORCP1header.Order = 1
PORCP1detail3Fields("PROCESSCMD").PutWithoutVerification ("1") ' Command
PORCP1detail3.Process
PORCP1headerFields("DATE").Value = MySet!DELDATE ' Receipt Date
PORCP1detail5Fields("FUNCTION").Value = "61" ' Function
PORCP1detail5.Process
PORCP1headerFields("STCODE").Value = MySet!LOCATION ' Ship-To Location
PORCP1headerFields("DESCRIPTIO").Value = "Del. Note: " & MySet!DELNOTENUM & " - Truck Reg.: " & MySet!TRUCKREG ' Description
PORCP1headerFields("REFERENCE").Value = MySet!INTREQNO ' Reference
PORCP1detail1Fields("RCPLREV").PutWithoutVerification ("-1") ' Line Number
PORCP1detail1Fields("RCPLREV").PutWithoutVerification ("-1") ' Line Number
PORCP1detail1.Read
temp = PORCP1detail1.Exists
temp = PORCP1detail1.Exists
'ERROR
PORCP1detail1Fields("LOCATION").Value = MySet!LOCATION ' Location
temp = PORCP1detail1.Exists
'ERROR
PORCP1detail1Fields("RQRECEIVED").Value = MySet!DELQTY ' Quantity Received
If MySet!DELQTY >= PORCP1detail1Fields("OQORDERED").Value Then
PORCP1detail1Fields("POCOMPLETE").Value = "-1" ' Completes PO
ElseIf (MySet!DELQTY - PORCP1detail1Fields("RQRECEIVED").Value) / PORCP1detail1Fields("OQORDERED").Value = 0.02 Then
PORCP1detail1Fields("POCOMPLETE").Value = "-1" ' Completes PO and Cancel Remainder
PORCP1detail1Fields("RQCANCELED").Value = MySet!DELQTY - PORCP1detail1Fields("RQRECEIVED").Value ' Quantity Canceled
Else
PORCP1detail1Fields("POCOMPLETE").Value = "-1" ' Completes PO - NO
End If
temp = PORCP1detail1.Exists
PORCP1detail1.Update
PORCP1detail1Fields("RCPLREV").PutWithoutVerification ("-1") ' Line Number
'ERROR
PORCP1detail1.Read
PORCP1detail3.Browse "(RCPHSEQ = " & MySeq & ")", 1
temp = PORCP1detail3.Exists
PORCP1detail3.RecordClear
PORCP1detail5Fields("FUNCTION").PutWithoutVerification ("10") ' Function
PORCP1detail5.Process
temp = PORCP1header.Exists
PORCP1header.Insert
MyDocNum = PORCP1headerFields("RCPNUMBER").Value ' Read Receipt number
PORCP1detail5Fields("RCPHSEQ").PutWithoutVerification (MySeq) ' Receipt Sequence Key
PORCP1detail5Fields("FUNCTION").PutWithoutVerification ("2") ' Function
'Update processed lines
DoCmd.SetWarnings False
DoCmd.RunSQL "Update dbo_DelNotes SET dbo_DelNotes.PROCESSED = -1, dbo_DelNotes.PROCDATE = #" & Format(Now(), "yyyy/MM/dd HH:mm:ss") & "#, dbo_DelNotes.RCPTNUM ='" & MyDocNum & "' where dbo_DelNotes.UnqID = " & MySet!UnqID
DoCmd.SetWarnings True
PORCP1detail5.Process
Dim POPRNT2 As AccpacCOMAPI.AccpacView
Dim POPRNT2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0640", POPRNT2
Set POPRNT2Fields = POPRNT2.Fields
Dim rpt As AccpacCOMAPI.AccpacReport
'ERROR AFTER EVERY COMMAND IN THIS SECTION
Set rpt = ReportSelect("PORCP01[PORCP01.RPT]", " ", " ")
Dim rptPrintSetup As AccpacCOMAPI.AccpacPrintSetup
Set rptPrintSetup = GetPrintSetup(" ", " ")
rptPrintSetup.DeviceName = "Feeds_copy&print_general"
rptPrintSetup.OutputName = "10.10.5.233"
rptPrintSetup.Orientation = 1
rptPrintSetup.PaperSize = 1
rptPrintSetup.PaperSource = 15
rpt.PrinterSetup rptPrintSetup
rpt.SetParam "RCPFROM", MyDocNum ' Report parameter: 2
rpt.SetParam "RCPTO", MyDocNum ' Report parameter: 3
rpt.SetParam "PRINTED", "1" ' Report parameter: 4
rpt.SetParam "QTYDEC", "4" ' Report parameter: 5
rpt.NumOfCopies = 1
rpt.Destination = PD_PREVIEW
rpt.PrintDir = ""
rpt.PrintReport
temp = POPRNT2.Exists
POPRNT2.Init
POPRNT2Fields("DOCTYPE").PutWithoutVerification ("3") ' Document Type
POPRNT2Fields("FROMRCP").PutWithoutVerification (MyDocNum) ' From Receipt Number
POPRNT2Fields("TORCP").PutWithoutVerification (MyDocNum) ' To Receipt Number
POPRNT2.Process
temp = PORCP1header.Exists
PORCP1header.Init
PORCP1header.Order = 0
PORCP1headerFields("RCPHSEQ").PutWithoutVerification ("0") ' Receipt Sequence Key
temp = PORCP1header.Exists
PORCP1header.Init
PORCP1header.Order = 1
temp = PORCP1detail1.Exists
PORCP1detail1.RecordClear
temp = PORCP1detail3.Exists
PORCP1detail3.RecordClear
temp = PORCP1detail4.Exists
PORCP1detail4.RecordClear
temp = PORCP1detail6.Exists
PORCP1detail6.Init
temp = PORCP1detail2.Exists
PORCP1detail2.Init
MySet.MoveNext
Loop
MySet.Close
Exit Function
ACCPACErrorHandler:
Dim lCount As Long
Dim lIndex As Long
If Errors Is Nothing Then
MsgBox Err.Description
Else
lCount = Errors.Count
If lCount = 0 Then
MsgBox Err.Description
Else
For lIndex = 0 To lCount - 1
MsgBox Errors.Item(lIndex)
Next
Err.Clear
End If
Resume Next
End If
End Function