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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent PO posting of PO invoices when different PO item values 1

Status
Not open for further replies.

johnhugh

Technical User
Mar 24, 2010
702
SG
Hi,

I'm using Accpac 6.
How could I prevent a PO invoice from being posted if the item cost of the PO invoice varies from the cost of the PO receipt?
 
Thanks. Is this something I would need the Accpac SDK for?
 
Could you give me some clues or an example on how to catch the event when the PO invoice line item price is being overwritten with a higher price?
I presume I have to create my own screen, pull the OCX onto my form and add some custom code?
Just not sure how to catch these events from the OCX.
 
Drop the OCX on a screen

Dim WithEvents dsInvoiceLine As Accpacpo1400.ACCPACDSControl

Private Sub dsInvoiceLine_OnRecordChanging(ByVal eReason As AccpacCOMAPI.tagEventReason, pStatus As AccpacCOMAPI.tagEventStatus, ByVal pField As AccpacDataSrc.IAccpacDSField, ByVal pMultipleFields As AccpacDataSrc.IAccpacDSFields)

' Your code here

End Sub

 
What about telling the user not to post the invoice if it differs from the PO?
 
Thanks tuba.
I've tried what you said, but cannot get my macro to pick up any changing event.
With the below code I've been testing with changing the bill to location but it won't get called.

Code:
Dim WithEvents dsInvoiceLine As Accpacpo1400.ACCPACDSControl
Private Sub dsInvoiceLine_OnRecordChanging(ByVal eReason As AccpacCOMAPI.tagEventReason, _
                                                pStatus As AccpacCOMAPI.tagEventStatus, _
                                                ByVal pField As AccpacDataSrc.IAccpacDSField, _
                                                ByVal pMultipleFields As AccpacDataSrc.IAccpacDSFields)

Select Case eReason
Case RSN_FIELDCHANGE
    If AccpacPO1400UICtrl1.UIAppControls("fecPOINVH_BillToLocation").Value = "20LUS" Then
          MsgBox ("test")
    End If
End Select

End Sub
 
Code:
Dim WithEvents dsInvoiceLine As Accpacpo1400.ACCPACDSControl
Private Sub dsInvoiceLine_OnRecordChanging(ByVal eReason As AccpacCOMAPI.tagEventReason, _
                                                pStatus As AccpacCOMAPI.tagEventStatus, _
                                                ByVal pField As AccpacDataSrc.IAccpacDSField, _
                                                ByVal pMultipleFields As AccpacDataSrc.IAccpacDSFields)

Select Case eReason
Case RSN_FIELDCHANGE
    IF pField.Name = "BTCODE" THEN
        IF pField.Value = "20LUS" THEN MsgBox "Test"
    END IF
[s]    If AccpacPO1400UICtrl1.UIAppControls("fecPOINVH_BillToLocation").Value = "20LUS" Then
          MsgBox ("test")
    End If
[/s]End Select

End Sub
 
Thanks DjangMan, but am still facing the same problem.
I bring up the PO invoice screen with my macro, pick a receipt to be invoiced and test it by changing the bill to field in the header to 20LUS.
Problem is, my macro won't even go into the select statement.
 
Does it get to the SELECT CASE line? If so, put a watch on pField and see what field is being changed and that should help you to get further along.
 
No. It seems to ignore the whole sub for some reason.
 
Are you changing the bill to address on the header? It appears, based on the name, that your dataset is connected to the detail lines.

How did you connect your dataset variable to the UIDatasource?
 
Thanks DjangMan.

I think I got it now.
I moved my dataset variable into the userform initialize sub.
Seems to be working now.
Code:
Option Explicit
Dim WithEvents dsInvoiceLine As AccpacPO1400.ACCPACDSControl
Private Sub dsInvoiceLine_OnRecordChanging(ByVal eReason As AccpacCOMAPI.tagEventReason, pStatus As AccpacCOMAPI.tagEventStatus, ByVal pField As AccpacDataSrc.IAccpacDSField, ByVal pMultipleFields As AccpacDataSrc.IAccpacDSFields)
On Error GoTo AccpacErrorHandler

' set data souce control to one of the UI data source controls
Select Case eReason
Case RSN_FIELDCHANGE
    If pField.Name = "UNITCOST" Then
        If pField.Value > 20 Then MsgBox "Test"
    End If
End Select

Exit Sub
AccpacErrorHandler:
    ReportErrors
End Sub

Private Sub UserForm_Initialize()
On Error GoTo AccpacErrorHandler

Set dsInvoiceLine = AccpacPO1400UICtrl1.UIDSControls(24)

Exit Sub
AccpacErrorHandler:
    ReportErrors
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top