web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

VBA

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Almas Mahfooz Profile Picture
    11,009 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.

  • Selva D Profile Picture
    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
    L Vail Profile Picture
    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans