Link to home
Start Free TrialLog in
Avatar of Gilbert777
Gilbert777

asked on

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

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?

ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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", _
        True)

    ' Open read-only Database object based on information in 
    ' the connect string.
    MsgBox "Opening pubs..."
    Set dbsPubs = wrkJet.OpenDatabase("Publishers", _
        dbDriverNoPrompt, True, _
        "ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")

    ' 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, _
        "ODBC;DATABASE=pubs;DSN=Publishers;")

    ' 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] = " & _
                    dbsLoop.Connection.Name
            Else
                Debug.Print "  " & prpLoop.Name & " = " & _
                    prpLoop
            End If
        Next prpLoop
        On Error GoTo 0

    Next dbsLoop

    dbsNorthwind.Close
    dbsPubs.Close
    dbsPubs2.Close
    wrkJet.Close

End Sub

Open in new window

Avatar of HooKooDooKu
HooKooDooKu

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)
Avatar of Gilbert777

ASKER

JDettman,
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?
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).
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
HooKooDooKu,
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?
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!