am using vb6 and ms office 2007 on Windows 7 professional platform

i wrote code as below

dim db as database
dim rs as recordset
dim ws as workspace

Private Sub Form_Load()
Set db = OpenDatabase(app.path & "\Contacts.mdb")
Set rs = db.OpenRecordset("Info", dbOpenTable)
End Sub

Now, when i run my code then and error call "run time error 13 - type mismatch"

i created my database with ACCESS 2000 and i have already installed SP6 for VB6
earlier i used XP and i never find this kind of error. i dnt find same problem with my earlier codes. i find this error in NEW codes only....

plz help, where i am going wrong...

Recommended Answers

All 5 Replies

I usually set db = CurrentDB, store the the db path in a string variable named path, (including the db extension at the end) and then when I set the recordset I can just do this, which will select all of the tables in your database:

Set rs = CurrentDb.OpenRecordset("SELECT Name " & _
                                    "FROM MSysObjects IN '" & path & "' " & _
                                    "WHERE Type=1 AND Flags=0")

Then when you want to select a particular object just do this:

Me.RecordSource = "SELECT * FROM [TableOrQuery] IN '" & path & "'"

When inserting/updating you will need a queryDef.

Member Avatar for gowans07

am using vb6 and ms office 2007 on Windows 7 professional platform

i wrote code as below

dim db as database
dim rs as recordset
dim ws as workspace

Private Sub Form_Load()
Set db = OpenDatabase(app.path & "\Contacts.mdb")
Set rs = db.OpenRecordset("Info", dbOpenTable)
End Sub

Now, when i run my code then and error call "run time error 13 - type mismatch"

i created my database with ACCESS 2000 and i have already installed SP6 for VB6
earlier i used XP and i never find this kind of error. i dnt find same problem with my earlier codes. i find this error in NEW codes only....

plz help, where i am going wrong...

How did you find installing SP6 on your computer? I've never managed to get it too work?

Office 2007 uses a different library. Someone had posted a similar problem a few months ago. I believe the Office 2007 Access uses a different database engine than the Jet engine (versions 2.x, 3.51, 4.0, etc.).

But use the following reference library from the Project/References menu: Microsoft Office 12.0 Access Database engine object Library. Access 2000 uses the Jet 4.0 engine, not the same engine as Access 2007.

VB6 was designed with the Jet Database engine as the database of engine of choice. However, it's nice to know that you can still use the newer up to date engines in this classic programming tool.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.