Is it possible to add a button to a Great Plains window and have VBA code open an existing Microsoft Access database when this button is clicked?
This can be done using Modifier and VBA.
1. Add a new button to the desired Great Plains window using Modifier.
2. Give this button a descriptive name such as btnOpenAccessDb.
3. Grant security to this modified window and then open the window itself in Great Plains.
4. Add the window to VBA and then add the new button to VBA as well.
5. Open the VBA editor and navigate to the code section for this Great Plains window. Following is a code sample that can be used here:
Dim appAccess As Object
Private Sub btnOpenAccessDb_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)
Set appAccess = CreateObject("Access.Application")
docAccess = appAccess.OpenCurrentDatabase("C:\My Documents\db1.mdb", True)
appAccess.Visible = True
Note -This code sample is designed to open adatabase named "db1.mdb" located in the C:\My Documents directory and can be changed as needed. The appAccess object should be dimensioned in the General Declarations section so that it persists beyond the scope of the button click event in which the code is firing.
This article was TechKnowledge Document ID:32879
Article ID: 861457 - Last Review: 13 Jul 2012 - Revision: 1