473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Currentdb.OpenRecordset fun

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
4 72288
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Vladislav Moltchanov | last post by:
I am making data entry tool in Acc2K for several data collecting centres. It is convenient to have several files (mde file, .mdb with tables only etc) located in the same directory. To make...
11
by: MLH | last post by:
If this is what MySQL is set to... SELECT DISTINCTROW qryVehiclesNowners5.SerialNum, qryVehiclesNowners5.VDescr, qryVehiclesNowners5.Owner, qryVehiclesNowners5.VehicleJobID ,...
0
by: mo. | last post by:
I need some help in accessing Jet database using DAO. I have just started to learn c# and am trying to rewrite a program I have in vb.net to c#. In VB.Net I can do this: Dim ws As...
0
by: Peter S | last post by:
Hi: I am trying to read a SQL Server text field (Access memo field) using connection.OpenRecordSet("qry with text field") rather than database.OpenRecordSet("qry with text field")
1
by: jnikle | last post by:
I have a parameter query named "qry_employee_info_reports" that I need to run in the OnOpen event of a form. I'm after its total number of records. The query's got several joins in it, and one of...
7
by: Tony M. | last post by:
I'm trying to execute an append query. I have a case that works, and one that returns an object not set error. THIS WORKS: Private Sub cmdArchiveRecs_Click() BeginTrans CurrentDb.Execute...
3
by: Richard Hollenbeck | last post by:
In DAO, is there any difference between "set db = CurrentDb()" with parentheses and "set db = CurrentDb" without parentheses? I'm just looking for data from a single field in a table inside the...
6
by: SpankyTClown | last post by:
I am trying to copy a record with child records. The process is to copy the parent and then search the child tables for record related to the parent. When I try to search the child table for all...
10
by: MLH | last post by:
Gentlemen: I am having one heck of a time taking a DAO walk through the records in an SQL dynaset. I'm trying to walk a set of records returned by a UNION query. I'm attempting to filter the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.