Calling Dynamics GP Lookup Using VBA – Method 2

Guys,

Few weeks ago I have posted a method to call GP lookup using VBA, but I have noticed that the account lookup form did not show data, so I looked into GP SDK and applied the account lookup calling through ExecuteSanScript function as shown below:

Dim GPApp As New Dynamics.Application
Dim ErrMsg As String
GPApp.CurrentProductID = 1493
Dim strCommand As String
strCommand = ” local   GLCOA_AccountLookupInfo LookupInfo.”
strCommand = strCommand + ” set ‘LookupInfo:Series’ to FINANCIAL.   {Series}” + vbNewLine
strCommand = strCommand + ” set ‘LookupInfo:Sort By’ to 4.          {Sort By Account Number}” + vbNewLine
strCommand = strCommand + ” set ‘LookupInfo:Post_Acct’ to POST_ACCT.{Show Posting Account}” + vbNewLine
strCommand = strCommand + ” set ‘LookupInfo:Post_Alloc_Acct’ to POST_ALLOC_ACCT.” + vbNewLine
strCommand = strCommand + ”                 {– Show Posting alloc Acct –}” + vbNewLine
strCommand = strCommand + ” set ‘LookupInfo:Active’ to false.       {No inactive accounts}” + vbNewLine
strCommand = strCommand + ” set ‘LookupInfo:Return Alias’ to false. {– Don’t return Alias –}” + vbNewLine
strCommand = strCommand + ” call Open of form Account_Lookup,” + vbNewLine
strCommand = strCommand + ” LookupInfo, ‘Account Number CS’ of window ‘GL_Account_Maintenance’ of form ‘GL_Account_Maintenance’, ‘Account Number CS’ of window ‘GL_Account_Maintenance’ of form ‘GL_Account_Maintenance’.” + vbNewLine
GPApp.ExecuteSanscript strCommand, ErrMsg

Now to get this lookup customized to your form and return the data to your field, there are two parameters need to be changed as explained below:

The primary function that will call the lookup is “call Open of form Account_Lookup” the function requires two parameters:

call Open of form Account_Lookup, “Initial Value”, “Field to set the returned value in”.

1. “Initial Value”: this is the value that will be passed to the lookup to initiate the search, by default you might need to use your customized field instead.

2. “Field to set the returned value in”: here you need to identify the field that the lookup will return the value in.

So basically replace “‘Account Number CS’ of window ‘GL_Account_Maintenance’ of form ‘GL_Account_Maintenance'” with your field name and place code above in your Lookup button and the form will show up and works!

Hope that this helps.

Regards,

Mohammad R. Daoud
MVP, MCP, MCBMSP, MCTS, MCBMSS
Software Development Manager
+962 – 79 – 999 65 85
Great Package For Business Solutions
daoudm@greatpbs.com
http://www.greatpbs.com

Advertisements

About Mohammad R. Daoud
Mohammad R. Daoud has been working as a Microsoft Dynamics GP consultant since 2004. His career path started with version 7.5; he studied every single tip of the application technicalities and did allot of successful implementations that includes functional consultations, analysis, and custom development projects. He holds a graduate degree in Computer Science and currently he is pursuing MBA degree in Accounting. In January 2007 he was nominated to the Microsoft Most Valuable Professional (MVP) certificate and was certified in April 2008 due to his online contributions in the Dynamics Community (Dynamics GP Newsgroups, Forums, User Groups and his blog: http://mohdaoud.blogspot.com). Worth to mention that he was also listed as one of the Microsoft Dynamics Top 100 Most Influential People in 2009 by DynamicsWorld. And more... • Demonstrated Passion for MS Products through participating in beta testing for some product versions, an effective member of Microsoft Connect. • Talented in securing strong high quality relationships with premier customers, partners and sales teams passionately and profitably. • Dedicated to meeting the expectations and requirements of internal and/or external customers • Problem Solver – Uses systematic approach to uncover true problem(s) and practical solution and can marshal resources to solve problem! • Proven record of effective account management, including Account Planning, Opportunity Management, and Business Management Excellence and working as part of a larger virtual team • Successful in delivering high quality technical engagements in the enterprise Dynamics GP implementations area according to customer requirements. • Dedicated, Committed, Self Motivated, Creative and highly focused with excellent communication, Negotiation, presentation, Active Listening and Objection Handling skills. • Experienced in Profitable researches and studies including white papers and technical presentations.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: