To use the example script, follow these steps:
- Open the Account Maintenance window in Microsoft Dynamics GP.
- On the Tools menu, click Customize, and then click Add Current Window to Visual Basic.
- On the Tools menu, click Customize, click Add Fields to Visual Basic, and then click the Account Number field, the Description field, and the User-Defined 1 field.
- On the Tools menu, click Customize, and then click Visual Basic Editor.
- In Visual Basic Editor, expand Great Plains Objects, and then double-click AccountMaintenance to open an Account Maintenance code window.
- Copy the following code, and then paste it into the Account Maintenance code window.
Private Sub Description_AfterGotFocus()
Dim objRec
Dim objConn
Dim cmdString
Set objRec = CreateObject("ADODB.Recordset")
Set objConn = CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=MSDASQL;DSN=GreatPlains;Initial Catalog=TWO;User Id=sa;Password=password"
objConn.Open
cmdString = "Select ACTINDX from GL00105 where (ACTNUMST='" + Account + "')"
Set objRec = objConn.Execute(cmdString)
If objRec.EOF = True Then
AccountMaintenance.UserDefined1 = ""
Else
AccountMaintenance.UserDefined1 = objRec!ACTINDX
End If
objConn.Close
End Sub
'-------------------------------------------------------------------------------------------------
You can also use the RetrieveGlobalsX.dll file as per for Microsoft Dynamics GP versions like 9 for 9.0, 8 for 8.0, to retrieve the same information that this script example retrieves.
No comments:
Post a Comment