Cannot open a table from a Access database file using VB5 
Author Message
 Cannot open a table from a Access database file using VB5

Hi all,

 I am trying to open a table in my database this way
    Dim wrkDefault As Workspace
    Dim dbsTeroMarine As Database
    Dim rstSystem As Recordset

    Set wrkDefault = DBEngine.Workspaces(0)
    Set dbsTeroMarine = wrkDefault.OpenDatabase(sDbaseName)
    ' sDbaseName is a global variable with the MDB dile name
    Set rstSystem = dbsTeroMarine.OpenRecordset("system")
    ' system is the name of the table in the Database file

But at this point I get an error during runtime: Runtime Error '13': Type
mismatch.

What could be the problem???
Should I create a tableDef before invoking the recordset or is there any
other way.
Could someone please give me a helping hand.

Thanks in advance.
Matts



Mon, 02 Apr 2001 03:00:00 GMT  
 Cannot open a table from a Access database file using VB5
Maybe change "system" to "SELECT * FROM system"
What's your path to sDbaseName?

J-

Quote:

>Hi all,

> I am trying to open a table in my database this way
>    Dim wrkDefault As Workspace
>    Dim dbsTeroMarine As Database
>    Dim rstSystem As Recordset

>    Set wrkDefault = DBEngine.Workspaces(0)
>    Set dbsTeroMarine = wrkDefault.OpenDatabase(sDbaseName)
>    ' sDbaseName is a global variable with the MDB dile name
>    Set rstSystem = dbsTeroMarine.OpenRecordset("system")
>    ' system is the name of the table in the Database file

>But at this point I get an error during runtime: Runtime Error '13': Type
>mismatch.

>What could be the problem???
>Should I create a tableDef before invoking the recordset or is there any
>other way.
>Could someone please give me a helping hand.

>Thanks in advance.
>Matts



Mon, 02 Apr 2001 03:00:00 GMT  
 Cannot open a table from a Access database file using VB5
Looks allright. The only thing I can think off is that there may be a reference to an objectlibrary (other than
DAO) with a different recordsetobject in it. You could try:

     Dim rstSystem As DAO.Recordset

Sjouke


Quote:
> Hi all,

>  I am trying to open a table in my database this way
>     Dim wrkDefault As Workspace
>     Dim dbsTeroMarine As Database
>     Dim rstSystem As Recordset

>     Set wrkDefault = DBEngine.Workspaces(0)
>     Set dbsTeroMarine = wrkDefault.OpenDatabase(sDbaseName)
>     ' sDbaseName is a global variable with the MDB dile name
>     Set rstSystem = dbsTeroMarine.OpenRecordset("system")
>     ' system is the name of the table in the Database file

> But at this point I get an error during runtime: Runtime Error '13': Type
> mismatch.

> What could be the problem???
> Should I create a tableDef before invoking the recordset or is there any
> other way.
> Could someone please give me a helping hand.

> Thanks in advance.
> Matts



Mon, 02 Apr 2001 03:00:00 GMT  
 Cannot open a table from a Access database file using VB5
Change the name of the table!  System is a reserved word in VB--generates a
million variation on the error you saw!!!

The type mismatch is that it is trying to open the SYSTEM object, which it
obviously can't do.

Try that.

Sharman Staples

Quote:

>Hi all,

> I am trying to open a table in my database this way
>    Dim wrkDefault As Workspace
>    Dim dbsTeroMarine As Database
>    Dim rstSystem As Recordset

>    Set wrkDefault = DBEngine.Workspaces(0)
>    Set dbsTeroMarine = wrkDefault.OpenDatabase(sDbaseName)
>    ' sDbaseName is a global variable with the MDB dile name
>    Set rstSystem = dbsTeroMarine.OpenRecordset("system")
>    ' system is the name of the table in the Database file

>But at this point I get an error during runtime: Runtime Error '13': Type
>mismatch.

>What could be the problem???
>Should I create a tableDef before invoking the recordset or is there any
>other way.
>Could someone please give me a helping hand.

>Thanks in advance.
>Matts



Tue, 03 Apr 2001 03:00:00 GMT  
 Cannot open a table from a Access database file using VB5

Quote:

>What could be the problem???
>Should I create a tableDef before invoking the recordset or is there any
>other way.
>Could someone please give me a helping hand.

All the posted suggestions look pretty good.  Definately reference the
object library every time you create an object.

You might also want to try looping through the tabledef objects and checking
their names to make sure that there really is a table named "system":

dim dbs as dao.database
dim tbl as dao.tabledef

set dbs = opendatabase()

for each tbl in dbs.tabledefs
    debug.print tabledef.name
next



Tue, 03 Apr 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Cannot open a table because table name uses accent letter

2. Microsoft Jet Database Engine Cannot Open The File.......(access)mdb

3. Microsoft Jet Database Engine Cannot Open The File.......(access)mdb

4. How do I open a Table in an Access database from VB5

5. Open different database file within Access using code

6. Help Access cannot open my Database

7. Cannot Open Access 97 Database without extension *.mdb with CR8.5

8. cannot access database tables

9. Using VB5.0 to access outlook express message database files

10. add records to access table fails with back cannot update read-only database

11. The Microsoft Jet database engine cannot open the file

12. The Microsoft Jet database engine cannot open the file

 

 
Powered by phpBB® Forum Software