By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,659 Members | 1,717 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,659 IT Pros & Developers. It's quick & easy.

A97: problem with Set rst = dbs.OpenRecordset("tblMyTable", dbOpenTable)

P: n/a
MLH
A runtime error 13 (type mismatch) occurs running the following line:

Set rst = dbs.OpenRecordset("tblMyTable", dbOpenTable)

What would be the most likely place I would find the source of the
error? The DAO code lines providing dependencies to this one are...

Dim dbs As Database, rst as RecordSet
Set dbs = CurrentDb

It seems so unusual to be encountering an error of this kind. I've
been using DAO for nearly a decade it seems and I don't remember
running into this problem before.
Nov 13 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
MLH wrote:
A runtime error 13 (type mismatch) occurs running the following line:

Set rst = dbs.OpenRecordset("tblMyTable", dbOpenTable)

What would be the most likely place I would find the source of the
error? The DAO code lines providing dependencies to this one are...

Dim dbs As Database, rst as RecordSet
Set dbs = CurrentDb

It seems so unusual to be encountering an error of this kind. I've
been using DAO for nearly a decade it seems and I don't remember
running into this problem before.


The first thing I would look at is the Dim statement.
Dim rst As Recordset
however, you say recordset. I was thinking it might be "Recordsets" or
"Databases" or something you aren't dimming correctly. But your code
looks OK in the email.

Try
Dim rst As Recordset
Set rst = Currentdb.OpenRecordset("tblMyTable", dbOpenTable)

Nov 13 '05 #2

P: n/a
I've gotten this message too in the past. There's been 2 fixes for me.
1) Make sure my references are set right and 2) it was because
"tbl..." was a linked table and therefore couldn't be opened with
dbOpenTable

Nov 13 '05 #3

P: n/a
MLH
On 21 Oct 2005 14:39:18 -0700, ma**********@hotmail.com wrote:
I've gotten this message too in the past. There's been 2 fixes for me.
1) Make sure my references are set right and 2) it was because
"tbl..." was a linked table and therefore couldn't be opened with
dbOpenTable


Maybe its references. The table = local. I just unchecked 3 references
& set one. The three I unchecked DISAPPEARED after unchecking
them. I have no way to REcheck them now. The only three I have
checked are:

Visual Basic for Applications
Microsoft Access 8.0 Object Library
Microsoft DAO 3.51 Object Library
Nov 13 '05 #4

P: n/a
On Fri, 21 Oct 2005 17:02:40 -0400, MLH <CR**@NorthState.net> wrote:
A runtime error 13 (type mismatch) occurs running the following line:

Set rst = dbs.OpenRecordset("tblMyTable", dbOpenTable)

What would be the most likely place I would find the source of the
error? The DAO code lines providing dependencies to this one are...

Dim dbs As Database, rst as RecordSet
Set dbs = CurrentDb

It seems so unusual to be encountering an error of this kind. I've
been using DAO for nearly a decade it seems and I don't remember
running into this problem before.


Replace dbOpenTable with dbOpenDynaset.

Nov 13 '05 #5

P: n/a
MLH wrote:
A runtime error 13 (type mismatch) occurs running the following line:

Set rst = dbs.OpenRecordset("tblMyTable", dbOpenTable)

What would be the most likely place I would find the source of the
error? The DAO code lines providing dependencies to this one are...

Dim dbs As Database, rst as RecordSet
Set dbs = CurrentDb

It seems so unusual to be encountering an error of this kind. I've
been using DAO for nearly a decade it seems and I don't remember
running into this problem before.


A97 sort of started working with ADO instead of DAO. Check the references.

To be even clearer, change your declarations thusly:

Dim dbs as DAO.Database
dim rst as DAO.Recordset
set dbs = CurrentDB '<--VBA is smart enough to get this right...

....as it'll avoid any namespace collisions if you have both ADO and DAO
referenced.

Nov 13 '05 #6

P: n/a
On Sat, 22 Oct 2005 00:19:02 GMT, Wayne Gillespie
<be*****@NOhotmailSPAM.com.au> wrote:

Why? dbOpenTable is perfectly valid.
-Tom.
On Fri, 21 Oct 2005 17:02:40 -0400, MLH <CR**@NorthState.net> wrote:
A runtime error 13 (type mismatch) occurs running the following line:

Set rst = dbs.OpenRecordset("tblMyTable", dbOpenTable)

What would be the most likely place I would find the source of the
error? The DAO code lines providing dependencies to this one are...

Dim dbs As Database, rst as RecordSet
Set dbs = CurrentDb

It seems so unusual to be encountering an error of this kind. I've
been using DAO for nearly a decade it seems and I don't remember
running into this problem before.


Replace dbOpenTable with dbOpenDynaset.


Nov 13 '05 #7

P: n/a
MLH
Getting back to the "Basic 3" references took care of the prob.
I wish I had tried removing ambiguity using the more strict syntax
you suggested for the Dim statements first. But, I didn't and I damn
sure don't wanna go backwards just for testing - scares the crap
out-a-me. I'm fairly certain it would have been effective.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
MLH wrote:
A runtime error 13 (type mismatch) occurs running the following line:

Set rst = dbs.OpenRecordset("tblMyTable", dbOpenTable)

What would be the most likely place I would find the source of the
error? The DAO code lines providing dependencies to this one are...

Dim dbs As Database, rst as RecordSet
Set dbs = CurrentDb

It seems so unusual to be encountering an error of this kind. I've
been using DAO for nearly a decade it seems and I don't remember
running into this problem before.


A97 sort of started working with ADO instead of DAO. Check the references.

To be even clearer, change your declarations thusly:

Dim dbs as DAO.Database
dim rst as DAO.Recordset
set dbs = CurrentDB '<--VBA is smart enough to get this right...

...as it'll avoid any namespace collisions if you have both ADO and DAO
referenced.


Nov 13 '05 #8

P: n/a
corey lawson <co**********@ayeteatea.net> wrote in
news:11*************@corp.supernews.com:
To be even clearer, change your declarations thusly:

Dim dbs as DAO.Database
dim rst as DAO.Recordset
set dbs = CurrentDB '<--VBA is smart enough to get this right...


CurrentDB occurs in two places in the Access object hierarchy (as
does DBEngine), once in the Access.Application object, and once in
DAO.

Because of that, you don't actually need a DAO reference to use
either CurrentDB or DBEngine. This means you can execute SQL with
Jet without needing a DAO reference.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #9

P: n/a
MLH <CR**@NorthState.net> wrote in
news:up********************************@4ax.com:
Getting back to the "Basic 3" references took care of the prob.
I wish I had tried removing ambiguity using the more strict syntax
you suggested for the Dim statements first. But, I didn't and I
damn sure don't wanna go backwards just for testing - scares the
crap out-a-me. I'm fairly certain it would have been effective.


Since you're in A97 and *not* using ADO, you can very easily to a
global search/replace (a new feature added after Access 2, probably
in A95). Just search for "As Recordset" and replace it with "As
DAO.Recordset" and you'll be set.

This is not terribly important in A97 by itself, but it's crucial
for any code that may get upgraded to a version of Access beyond 97,
where DAO was not a default reference, and where you could easily
have both ADO and DAO references in a single MDB file.

Get in the habit of doing it. You'll be glad you did when it comes
time to try using ADO for one of the handful of things it offers
that DAO lacks.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.