Dear All,
I am writing some vba codes to alert the user that number he/she is putting on Debtor PO number field in Sales Transaction Entry window have been used or not.
Am using sop10100 and sop30200. But my first test only include sop10100.
Unfortunately my codes are not responding to my expectation.
Below is my code
Private Sub DebtorPONumber_AfterGotFocus()
Dim objRec
Dim objConn
Dim cmdString
Set objRec = CreateObject("ADODB.Recordset")
Set objConn = CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=MSDASQL;DSN=GP;DataSource=.;Initial Catalog=TWO;User Id=sa;Password=allowme@1"
objConn.Open
'cmdString = "select cstponbr from (select cstponbr from SOP10100 union select cstponbr from SOP30200)a where (a.cstponbr='" + CUSTPONMBR + "')"
Do While Not objRec.EOF
MsgBox "the po" & " " & CSTPONBR & " " & "has been used"
objRec.MoveNext
Loop
objConn.Close
'End If
End Sub
Kindly assists on where am going wrong.
RonRyan
*This post is locked for comments
Have you tried using the SOP PO Number Check module of the Professional Services Tools module?
Kind regards,
Leslie
1. You are not assigning your result to record set.
2. In loop please add to verify your condition and display the message.
You are not executing your command also customer po number is not passing.
Also change your event to CustomerPONumber_BeforeUserChanged.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,219 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156