running a Access 97 .mdb database through Visual Basic...still giving me -2147024894 cannot find file specified but exists!

Posted on 2005-05-02
Last Modified: 2012-05-05
I've got the following coding:

Dim Wsh As New WSHShell
    'Set Wsh = CreateObject("WScript.Shell")
    Dim LocalDb As String
        ''set the localdb to the exact path and filename to the database you want opening
    LocalDb = "C:\Fkpuds\Template\schedulemaker.mdb"
    Wsh.Run "msaccess""" & LocalDb & "", WshMaximizedFocus
    Set Wsh = Nothing

to open up and run an Access 97 database.
I get a Run-time 'error' -2147024894 error:  Automation error: the System cannot find file specified.
with the highlight on Wsh.Run "msaccess""" & LocalDb & "", WshMaximizedFocus

When I do a print LocalDb, I get:

When I do a print Dir(LocalDb), I get:

When I go to Windows Explorer and click on all the folders and subfolders - I can see the file present.

All I want to do is run this .mdb database.  There is a form startup that runs all kinds of macros...I even took off the startup form and it still does not see it.  The .mdb database is not read-only nor is the folder.
It's just real frustrating that its there and not working.
Is there another set of code that I can use in Visual Basic to make this access database pull and run?
Thank you in advance for all replies.
Question by:stephenlecomptejr
    LVL 13

    Accepted Solution

    Hi stephenlecomptejr,
    I think the problem could be that it can't find MSAccess (at least in the path). What you can do is shell directly to the MDB-file, which should start it in access, if it's available. Try:
    Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    and then
    Call ShellExecute(0&, "open", LocalDb, vbNullString, vbNullString, vbMaximizedFocus)
    It will act like when you double-click on the file in the explorer. You can use this for any file that has a shell extention for opening it.
    LVL 1

    Author Comment

    thank you, thank you, thank you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    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…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    737 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

    18 Experts available now in Live!

    Get 1:1 Help Now