21 February, 2009

How to make PO field required for specific customer


This requirement came up last week and after Mariano explained how to do it, I went ahead and did it... for fun. Sick, I know.

I posted an example of using the DUOS a couple of year ago and used that, with very few tweaks, after using Modifier to add a Check Box control to the Customer Maintenance window to store the RequiredPO flag in the DUOS (SY90000) as Mariano suggested. If you have problems converting that example to this scenario let me know and I will e-mail you the code.

After that, all you have to do is add the Sales Transaction Entry Window and the Customer ID and Customer PO Fields on that window to your Visual Basic Project. Open the VB Editor and add this code to the SalesTransactionEntry (Window) to make the Customer PO field required for selected customers:

Option Explicit
Dim Msg, Style, Title, Help, Ctxt, Response, MyString, Default
Dim ItemCollection As DUOSObjects
Dim ItemObject As DUOSObject

Private Sub CustomerID_Changed()

On Error GoTo Proc_Error:

Set ItemCollection = DUOSObjectsGet("Customer")

If CustomerID.Empty = False Then
Set ItemObject = ItemCollection(CustomerID)
If ItemObject.Properties("RequirePO") = "1" Then
CustomerPONumber.Required = True
Else
CustomerPONumber.Required = False
End If
End If

Exit Sub

Proc_Error: MsgBox Error$ & " " & Error, vbOKOnly, "CustomerID_Changed"

End Sub

2 comments:

Mariano Gomez said...

Nice! Very Nice! It's great to see your ideas materialized and prove to the community that some of these suggestions are easier to put into play than what they may seem.

Keep up the good work!

MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com

Rachat de credit said...

It was a great help, many thanks, now to make po field required for specific customer is easy with your help. Kudos