I am using this function to calculate the sum of all PO using a particular accountnumber in a specific Year. I created a view in PVS8 which runs fine (POCTB). When I run this function I get the following Runtime error:
Runtime error 2147467259 (80004005) View: POCTB. View Call Failed.
Help anyone please!
Function CalculatePOTotals(ByVal AccNr As String, FiscalYr As String) As Double
Dim POTOT As ACCPACXAPILib.xapiView
'Set Session = CreateObject("ACCPAC.xapisession")
Session.Open "ADMIN", "V1PER", "CTBDAT", Date, 0
Set POTOT = Session.OpenView("POCTB", "PO")
CalculatePOTotals = 0
POTOT.Init
POTOT.Browse "ITEMNO= " & AccNr, 1
POTOT.Fetch
Do While POTOT.Fetch
If Left$(POTOT("DATE"), 4) = FiscalYr And Trim(POTOT("ITEMNO")) = AccNr Then
Total = Total + CDbl(Trim(POTOT("OQORDERED"))) * CDbl(Trim(POTOT("UNITCOST"))) * CDbl(Trim(POTOT("Rate")))
End If
Loop
POTOT.Cancel
CalculatePOTotals = Total
End Function
Runtime error 2147467259 (80004005) View: POCTB. View Call Failed.
Help anyone please!
Function CalculatePOTotals(ByVal AccNr As String, FiscalYr As String) As Double
Dim POTOT As ACCPACXAPILib.xapiView
'Set Session = CreateObject("ACCPAC.xapisession")
Session.Open "ADMIN", "V1PER", "CTBDAT", Date, 0
Set POTOT = Session.OpenView("POCTB", "PO")
CalculatePOTotals = 0
POTOT.Init
POTOT.Browse "ITEMNO= " & AccNr, 1
POTOT.Fetch
Do While POTOT.Fetch
If Left$(POTOT("DATE"), 4) = FiscalYr And Trim(POTOT("ITEMNO")) = AccNr Then
Total = Total + CDbl(Trim(POTOT("OQORDERED"))) * CDbl(Trim(POTOT("UNITCOST"))) * CDbl(Trim(POTOT("Rate")))
End If
Loop
POTOT.Cancel
CalculatePOTotals = Total
End Function