Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)
Posted on by

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

  • Suggested answer
    L Vail Profile Picture
    L Vail 65,271 on at
    RE: VBA

    Have you tried using the SOP PO Number Check module of the Professional Services Tools module?

    Kind regards,

    Leslie

  • Selva D Profile Picture
    Selva D 65 on at
    RE: VBA

    1. You are not assigning your result to record set.

    2. In loop please add to verify your condition and display the message.

  • Suggested answer
    Almas Mahfooz Profile Picture
    Almas Mahfooz 11,003 User Group Leader on at
    RE: VBA

    You are not executing your command also customer po number is not passing.

    Also change your event to CustomerPONumber_BeforeUserChanged.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans