Open MS Access from Visual Basic Form

Posted on 2006-05-26
Last Modified: 2013-11-25
Can I place a control (button) on a VB form that will launch an Access application? If so, how is that done?
Question by:EMCIT
    LVL 65

    Accepted Solution


    In your VB Editor screen you should see a command button icon.  Click on the command button icon, then click-and-hold where you want the upper left of the button, drag to where you want the lower right of the button, then release.  You should see a command button.
    Double-click on the command button to get to the VB Code Editor.  

    You should see this in code...

    Private Sub Command1_Click()

    End Sub

    ... now modify it to look like this...

    Private Sub Command1_Click()
    Dim v

    Dim sAccess As String
    Dim sYourApp As String

    sAccess = "c:\Program Files\Microsoft Office\Office\msaccess.exe"   '<--- Change if you are using a version higher than A2K
    sYourApp = "c:\db1.mdb"   '<-- Change to wherever your app is

    v = Shell(sAccess & " " & sYourApp, vbMaximizedFocus)

    End Sub

    Save, then run.

    Hope this helps.

    LVL 9

    Expert Comment

    Yes you can do it.
    On Click event of that command button call the executable file name using shell command.
    Normally the access executable file is stored in C:\Program Files\Microsoft Office\Office10\.
    you can call that executable using the following command for example

    Shell "C:\Program Files\Microsoft Office\Office10\MSACCESS"

    the above example calls the msaccess executable(i.e. application) for MS Office XP.

    please check the application's executable location according to your version.

    LVL 9

    Expert Comment

    oops little bit slower response.
    LVL 65

    Expert Comment

    I prefer the use of the API call ShellExecute

    Specify full pathname of file and it will open it using the registered program
    LVL 65

    Expert Comment

    by:Jim Horn
    Thanks for the grade.  Good luck with your project.  -Jim

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now