Using Modifier for VBA to Sort the Vendor Lookup by Name
Since most users look up vendors by vendor name, you can make the Dynamics GP’s Vendor Lookup window sort by the vendor’s name when the window opens using the Modifier with VBA tool. This tool may be active based on your current registration keys; if you don’t have access to the tool, you can purchase the license through your Dynamics GP partner.
To sort the Vendor Lookup window by the vendor’s name, follow these steps.
- Navigate to Cards | Purchasing | Vendor to open the Vendor Maintenance window.
- When you click the Vendor ID Lookup button, the Vendor Lookup window opens. Click Tools | Customize | Add Current Window to Visual Basic. This will add the Smartlist Vendor Lookup window to the Visual Basic project.
- The next step is to click Tools | Customize | Add Fields to Visual Basic. This mouse pointer will change modes to let you know that you are in the Add Fields mode.
- Next, click the Vendor Name column above the scrolling window to add the Vendor Name sort-by button to the Visual Basic project.
- At this point, we have added the window and field we need to work with to the Visual Basic project. The next step is to click Tools | Customize | Visual Basic Editor, which opens the Visual Basic project window.
- Open the Smarlist folder, then click Window and the After Activate event from the drop-down lists. The AfterActivate event occurs when a window is activated. A window is activated when it's moved from the background to the foreground in an application. This will ensure the VBA code will execute after the window is activated, sorting by the vendor’s name. You'll need to insert the VendorName.Value = 2 code to sort the lookup window’s contents by vendor name.
To test the VBA code, open the Vendor Lookup window. The vendors should now automatically be sorted by vendor name.
You'll notice in the window above that there is a period after the Vendor Name window. This tells you there's a VBA code active on this particular window. The VBA code is stored in a file with the .vba extension in the Dynamics GP client’s folder. This code only works on this particular workstation and will need to be installed on users’ workstations.
You can install it on other workstations by creating a package file through the Customizations Maintenance window and importing it to each workstation. Click Tools | Customize | Customization Maintenance to open the Customizations Maintenance window.