Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

TechKnowledge Content

Issue


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?


Resolution


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:


Option Explicit

Dim appAccess As Object


Private Sub btnOpenAccessDb_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)


Dim docAccess


Set appAccess = CreateObject("Access.Application")

docAccess = appAccess.OpenCurrentDatabase("C:\My Documents\db1.mdb", True)

appAccess.Visible = True


End Sub


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

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×