Allot of question comes to our minds when customizing GP on how to open GP lookup form while we are using VBA, here in this post, I will explain a simple workaround in details.
To get this done easily, we need to take the customer card as example, I will add a new lookup button and a new text field, the lookup button will call the lookup form and the value (Customer ID) will be placed in the text.
A. Customer Card Work:
1. Modify customer card form and add two objects, a lookup button and a string text box.
2. Add the “Modified” customer card form to VBA, and then add our lookup button with the text to VBA.
3. Now we need to add a Global Boolean variable to determine wither the lookup is called from this customized button or not.
4. On the button “Changed” event we need to call the customer lookup form, and this will require using Dynamics Continuum API, so you need first to add your reference to the API by following steps below:
a. On your VBA window go to Tools >> References
b. Check on “Dynamics Continuum Integration Library”
Then write the following code in the customer maintenance form:
Public bolFireLookup As Boolean
B. Customer Lookup Work:
1. Add the customer lookup form to VBA, and then add the Customer ID field and the select button.
2. As the Smart-list is a separate module that GP and has its own dictionary, you will need to reference the Dynamics_GP project by following steps below:
a. Go to Tools >> References
b. Check “Microsoft_Dynamics_GP”
3. Paste the following code:
|Private Sub Select_Changed() |
'Validate that the Customer Card is open
If Microsoft_Dynamics_GP.CustomerMaintenance.IsLoaded Then
'Validate that the lookup is called from customized lookup button
If Microsoft_Dynamics_GP.CustomerMaintenance.bolFireLookup Then
Microsoft_Dynamics_GP.CustomerMaintenance.txtCustomerID.Value = CustomersandProspectsDetail.CustomerNumber.Value Microsoft_Dynamics_GP.CustomerMaintenance.bolFireLookup = False
The complete sample package could be downloaded using the following link:
Hope that this helps.