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

Currentdb.OpenRecordset fun

P: n/a
I think I may have lost the plot. Just a few years ago I'm sure I wrote
something similar to the following code:

dim rst as recordset
set rst = currentdb.openrecordset("mytable")

' blah blah blah

rst.close

I'm sure this should work now, but it doesn't.. When I run it I get a type
mismatch on the second line (set rst.. etc). Perhaps this might be a
missing reference? Currently selected references for the project are:

Visual Basic for Applications
Microsoft Access 10.0 Object library
OLE automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft DAO 3.6 object library

I think it's the last one that should enable the code to work (is currentdb
part of DAO object library?) Or am I missing a reference? Any ideas what
is going on? I'm sure the code should work.. !

Thanks in advance.

Matt


Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Matt, the trouble is that both the DAO library and the ADO library have a
Recordset object.

You have listed the ADO library above DAO, so you get an ADO recordset from:
dim rst as recordset
When you try to assign a DAO recordset to it, it fails.

The solution is to be explicit about which recordset you want, i.e.:
dim rst as DAO.recordset

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Matt Parkins" <ma**@NOSPAMPRETTYPLEASEparkins.uk.net> wrote in message
news:OI*****************@news-binary.blueyonder.co.uk...
I think I may have lost the plot. Just a few years ago I'm sure I wrote
something similar to the following code:

dim rst as recordset
set rst = currentdb.openrecordset("mytable")

' blah blah blah

rst.close

I'm sure this should work now, but it doesn't.. When I run it I get a type mismatch on the second line (set rst.. etc). Perhaps this might be a
missing reference? Currently selected references for the project are:

Visual Basic for Applications
Microsoft Access 10.0 Object library
OLE automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft DAO 3.6 object library

I think it's the last one that should enable the code to work (is currentdb part of DAO object library?) Or am I missing a reference? Any ideas what
is going on? I'm sure the code should work.. !

Nov 12 '05 #2

P: n/a
YES! Thanks, that worked! Spot on!

Thanks man.

Matt

"Allen Browne" <ab***************@bigpond.net.au> wrote in message
news:nk*******************@news-server.bigpond.net.au...
Matt, the trouble is that both the DAO library and the ADO library have a
Recordset object.

You have listed the ADO library above DAO, so you get an ADO recordset from: dim rst as recordset
When you try to assign a DAO recordset to it, it fails.

The solution is to be explicit about which recordset you want, i.e.:
dim rst as DAO.recordset

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Matt Parkins" <ma**@NOSPAMPRETTYPLEASEparkins.uk.net> wrote in message
news:OI*****************@news-binary.blueyonder.co.uk...
I think I may have lost the plot. Just a few years ago I'm sure I wrote
something similar to the following code:

dim rst as recordset
set rst = currentdb.openrecordset("mytable")

' blah blah blah

rst.close

I'm sure this should work now, but it doesn't.. When I run it I get a

type
mismatch on the second line (set rst.. etc). Perhaps this might be a
missing reference? Currently selected references for the project are:

Visual Basic for Applications
Microsoft Access 10.0 Object library
OLE automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft DAO 3.6 object library

I think it's the last one that should enable the code to work (is

currentdb
part of DAO object library?) Or am I missing a reference? Any ideas what is going on? I'm sure the code should work.. !


Nov 12 '05 #3

P: n/a
Matt Parkins wrote:
I think I may have lost the plot. Just a few years ago I'm sure I wrote
something similar to the following code:

dim rst as recordset
set rst = currentdb.openrecordset("mytable")

' blah blah blah

rst.close

I'm sure this should work now, but it doesn't.. When I run it I get a type
mismatch on the second line (set rst.. etc)

Hi Matt

Now Access is becoming more ADO-ish, I think you need to be more
specific about what type of recordset you use. Try this:

dim rst as DAO.recordset
set rst = currentdb.openrecordset("mytable")

' blah blah blah

rst.close

Hope this helps.

Mark
Nov 12 '05 #4

P: 2
Move the DAO reference above the ADO reference and the problem should go away. You are using a DAO chunk of code and the ADO is trying to run it.

I think I may have lost the plot. Just a few years ago I'm sure I wrote
something similar to the following code:

dim rst as recordset
set rst = currentdb.openrecordset("mytable")

' blah blah blah

rst.close

I'm sure this should work now, but it doesn't.. When I run it I get a type
mismatch on the second line (set rst.. etc). Perhaps this might be a
missing reference? Currently selected references for the project are:

Visual Basic for Applications
Microsoft Access 10.0 Object library
OLE automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft DAO 3.6 object library

I think it's the last one that should enable the code to work (is currentdb
part of DAO object library?) Or am I missing a reference? Any ideas what
is going on? I'm sure the code should work.. !

Thanks in advance.

Matt
Mar 3 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.