How to determine why a VB6 call to an external function gives error.

Posted on 2011-04-28
Last Modified: 2012-05-11
I have a VB6 app (I'll call it A) which uses it's own Access 2000 file to store data. The app has been in successful use for some time. When I install and then uninstall another VB6 app (I'll call it B) which also works with an Access 2000 database file, A gives a runtime error 438 'Object doesn't support this property or method.' I think this is probably because it can no longer find a required shared file.

By doing some logging, I have determined that the error occurs in the statement:
Set rsQuotes = OpenDatabase("Quotes")

Open in new window

I have tried looking in the Project>Components and in the Object browser to determine precisely what file the code will look for to find this OpenDatabase function. I cannot find it anywhere.

Other sources seem to point to the dao360.dll file, but I still cannot find where my VB6 project specifies what shared file to find it in.

Other info that may be relevant:
The error no longer occurs if I re-install B.
The problem shows up on my XP SP3 test platform on which the only other installed app is MS Office, but does not show up on my development machine with lots of other software installed.

Any advice on how to find out where my VB6 code will look to find the OpenDatabase function in the above code? Any other suggestions on how I might be able to isolate the cause of the error?

Question by:Gilbert777
    LVL 56

    Accepted Solution

    OpenDatabase() is indeed a call into DAO.  Your VB6 app finds it through the project references:

     Screen shot
     It may be possible that it needs to be re-registered if you already have the reference.

    LVL 44

    Expert Comment

    The snippet below is an example of the OpenDataBase method in VBA for Access 2003.  Note how the VBA version first establishes a Workspace for the application.
    Sub OpenDatabaseX()
        Dim wrkJet As Workspace
        Dim dbsNorthwind As Database
        Dim dbsPubs As Database
        Dim dbsPubs2 As Database
        Dim dbsLoop As Database
        Dim prpLoop As Property
        ' Create Microsoft Jet Workspace object.
        Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
        ' Open Database object from saved Microsoft Jet database 
        ' for exclusive use.
        MsgBox "Opening Northwind..."
        Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb", _
        ' Open read-only Database object based on information in 
        ' the connect string.
        MsgBox "Opening pubs..."
        Set dbsPubs = wrkJet.OpenDatabase("Publishers", _
            dbDriverNoPrompt, True, _
        ' Open read-only Database object by entering only the 
        ' missing information in the ODBC Driver Manager dialog 
        ' box.
        MsgBox "Opening second copy of pubs..."
        Set dbsPubs2 = wrkJet.OpenDatabase("Publishers", _
            dbDriverCompleteRequired, True, _
        ' Enumerate the Databases collection.
        For Each dbsLoop In wrkJet.Databases
            Debug.Print "Database properties for " & _
                dbsLoop.Name & ":"
            On Error Resume Next
            ' Enumerate the Properties collection of each Database 
            ' object.
            For Each prpLoop In dbsLoop.Properties
                If prpLoop.Name = "Connection" Then
                    ' Property actually returns a Connection object.
                    Debug.Print "  Connection[.Name] = " & _
                    Debug.Print "  " & prpLoop.Name & " = " & _
                End If
            Next prpLoop
            On Error GoTo 0
        Next dbsLoop
    End Sub

    Open in new window

    LVL 16

    Expert Comment

    I know this is a similar error I get when I try to open an older Access Database (in this case, Access 2000 IS an "older" database) with Access 2007.  In my case, the databases are on a CD, and I have to copy them to the harddrive and let Access 2007 do some sort of conversion on them before it will open them.  It still comes up with a similar error, but then I can get to my database.

    In my VB6 applications, I'm using the "Microsoft DAO 3.6 Object Library" as shown in JDettman's screen shot above.  However, rather than simply calling "OpenDatabase()", I first call CreateWorkspace, and then open the database from the workspace:

    Dim WS as DAO.Workspace
    Dim DB as DAO.Database
    Set WS = CreateWorkspace("", "ADMIN", "", dbUseJet)
    Set DB = WS.OpenDatabase(FileName)

    Author Comment

    Your screenshot looks like at least part of what I am looking for. My problem is that I cannot find the menu command to access it. Help says to look at menu Project>References, but I do not have that item on the Project menu. Is there some other way to access the references dialog?
    LVL 16

    Expert Comment

    Are you really using VB6 IDE?  Or are you using VBA in Access?

    If you click on menu option Help->About Microsoft Visual Basic and see Microsoft Visual Basic 6.0 (SP6), then your Project menu should include a "Referencess..." option and a "Components..." option (among others).
    LVL 16

    Assisted Solution

    If you indeed are using VB6, there is the possibility that you are using custom menus and toolbars.  If that is the case, here's how to create a custom toolbar that will give you access to the References window:

    Right-click in a clear area of your menu or toolbar.  A popup menu should appear that should include "Customize..." at the bottom.  Select Customize.

    A Customize window will open up.  Make sure you select the "Toolbars" tab, and then click the "New..." button on the Toolbars tab.  A window will pop-up asking you to enter a name for the new toolbar.  Key any name you want, or just select the default one that is provided and click OK.

    You should now have a floating toolbar with the name you selected (it might be hiding behind the Customize window, so you might need to move it or close it and reopen it).

    In the customize window, click on the "Commands" tab.  You should see two list boxes.  The one one the left shows menu choises, the one on the right shows the sub-menu choises for what ever is currently selected on the left.  Select "Project" from the left list box.  The right list box should show various commands such as "Add Form".  Scroll down that list until you find the "References..." command.  Now drag-n-drop the references command on to your new toolbar and Close the Customize window.

    You should now be able to display the References window by clicking on the item in your custom toolbar.

    You can also follow these instructions to simply drag-n-drop the Resource command to any of your existing menus or toolbars.

    Author Comment

    I am using Visual Studio 6.0, enterprise edition.
    Help>About: Microsoft Visual Basic 6.0 (SP6), For 32 bit Windows Development.

    I know it seems peculiar, but I have no  'References' item in the project menu. I looked at Options to see if there is some sort of control over which menu items show but can't find anything.

    So what could make the menu item disappear?

    Author Comment

    After getting to my VB6 Project References dialog and finding dao360.dll there, I re-registered it with Windows; My app now runs without error!
    Thanks all!

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 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

    16 Experts available now in Live!

    Get 1:1 Help Now