Site Search:
Sign in | Join | Help
4Penny.net

Dynamics GP

Notes, Tips and Tricks on Developing in Dynamics GP

Sample code for using RetrieveGlobals9 in Dynamics

Here is a short piece of code that demonstrates how to code for RetrieveGlobals9.dll in Dynamics GP

 Private Sub NextCust_Changed()

    If Me.CustomerID.Value > "" Then
        MsgBox "The Customer Number Field must be empty"
        Exit Sub
    End If
   
    Dim cmd
    Dim rst
    Set userinfo = CreateObject("RetrieveGlobals9.retrieveuserinfo")
    Set conn = userinfo.Connection
   
    'Create an ADO command object.
    Set cmd = CreateObject("ADODB.Command")
   
    'set the database to the currently logged in db.
    conn.DefaultDatabase = userinfo.intercompany_id()

    cmd.ActiveConnection = conn
    cmd.CommandType = 4 'adCmdStoredProc
   
    'Get the next cust number
    cmd.CommandText = "_4P_SOPgetNextCustomerNumber"
    Set rst = cmd.Execute
    If Not rst.EOF Then
        Me.CustomerID.Value = rst("vchrCustomerNumber")
    End If
   
    'Close the connection.
    If conn.State = 1 Then
       conn.Close
    End If
   
    'Cleanup.
    Set cmd = Nothing
    Set cn = Nothing

End Sub

Comments

 

barb said:

thanks!

April 9, 2008 10:10 AM

Leave a Comment

(required)  
(optional)
(required)  
Add

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.