VBA - Creating a keyboard shortcut for a Microsoft Dynamics GP window expansion button

Well, I had been absent (more like out of ideas) from writing any new VBA articles. The truth is, they are hard to come by without giving away too many secrets. :-)

However, this one is worth giving away as I have seen many users request this feature to speed up data entry and processing. Take for example the Purchase Order Entry window. Won't you just like the ability to press some combination of keys on your keyboard to quickly access the Vendor Detail Entry window where you can quickly change around shipping methods, or other information needed? Well this example shows just that, but can be used to add shortcuts to any other button control in any other Dynamics GP window.

The solution is simple:

1) Add a pixel size button to the window with Modifier.




2) Caption the button. Buttons can have captions preceeded with the ampersand ("&") character, which in turn acts like a shortcut when used in combination with the Alt key on the keyboard.



As a personal choice, I captioned the button with &4, as the expansion button is Expansion Button 4.

3) In addition, we can change the button's Visual properties to blend it in with the expansion button. I particularly prefer to stack these shortcut buttons on top of or next to the expansion button they will serve as a shortcut for.



4) The button can then be added to VBA where code can be written to force the execution the expansion button Change script. To run the Expansion Button 4 change script that will open the window, we use the Dynamics Continuum Integration library and pass-through Dexterity Sanscript.


Private Sub 4_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)
Dim CompilerApp As Object
Dim CompilerMessage As String
Dim CompilerError As Integer
Dim Commands As String

' Create link without having reference marked
Set CompilerApp = CreateObject("Dynamics.Application")
Commands = ""
Commands = Commands & "run script 'Expansion Button 4' of window POP_PO_Entry of form POP_PO_Entry;"

' Execute SanScript
CompilerError = CompilerApp.ExecuteSanscript(Commands, CompilerMessage)
If CompilerError <> 0 Then
MsgBox CompilerMessage
End If
End Sub


The following -- and much simpler! -- code will also do the trick for you non-Dexterity developers:

Private Sub 4_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)
ExpansionButton4.Value = 1
End Sub

You will need to add the expansion button to VBA in addition to the pixel size button for the above code to work.

Very simple! Now when you go to the Purchase Order Entry screen, enter PO number and select a vendor, you can press Alt + 4 on the keyboard to open the associated window to the Vendor ID expansion button.

Hope you find this sample project useful.

Downloads

v10 - Sample Expansion Button shortcut package file - click here.

Until next post!

MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/

Comments

Popular posts from this blog

DBMS: 12 Microsoft Dynamics GP: 0 error when updating to Microsoft Dynamics GP 2013 R2

Cannot insert the value NULL into column 'CONTACT' error when clicking on Items List in Navigation Pane

How to uninstall Microsoft Dynamics GP 10.0 if you cannot uninstall it by using the "Add or Remove Programs" feature