473,513 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Type Mismatch on ADODB.Recordset

25 New Member
Hello,

I am debugging the following lines of code and am getting a "type mismatch 13" error on the Set rs = line.

Dim rs As Recordset

Set rs = CreateObject("ADODB.Recordset")

I am running MS-ACCESS 2000 and have added ADO library 2.8. I also have defined my ODBC connection to the network.

What am I doing wrong?

Thanks,
Gregg
Apr 10 '07 #1
10 8340
MMcCarthy
14,534 Recognized Expert Moderator MVP
You have to define the database.
Expand|Select|Wrap|Line Numbers
  1. Dim db As Database
  2. Dim rs As Recordset
  3.  
  4. Set db = CurrentDB
  5. Set rs = db.CreateObject("ADODB.Recordset")
  6.  
Apr 10 '07 #2
pks00
280 Recognized Expert Contributor
Hello,

I am debugging the following lines of code and am getting a "type mismatch 13" error on the Set rs = line.

Dim rs As Recordset

Set rs = CreateObject("ADODB.Recordset")

I am running MS-ACCESS 2000 and have added ADO library 2.8. I also have defined my ODBC connection to the network.

What am I doing wrong?

Thanks,
Gregg
Why are you creating an object if u have the reference checked? There is no reason to do this, just stick with new. Also u have have DAO checked and that also has a Recordset property so its always best to specify which one

eg

dim rs as ADODB.Recordset

set rs = new ADODB.Recordset


for createobject, u would typically use it this way

dim rs as object

set rs=createobject("ADODB.Recordset")



Hi Mary, long time no see :)
question for you: dont u use currentdb for DAO?

to use the current database for ado, u would use
currentproject.connection

eg

rs.Open "mysql", currentproject.connection, adOpenStatic, adLockPessimistic
Apr 10 '07 #3
ADezii
8,834 Recognized Expert Expert
Hello,

I am debugging the following lines of code and am getting a "type mismatch 13" error on the Set rs = line.

Dim rs As Recordset

Set rs = CreateObject("ADODB.Recordset")

I am running MS-ACCESS 2000 and have added ADO library 2.8. I also have defined my ODBC connection to the network.

What am I doing wrong?

Thanks,
Gregg
The correct Syntax is:
Expand|Select|Wrap|Line Numbers
  1. Dim MyRS As ADODB.Recordset
  2. Set MyRS = New ADODB.Recordset
Apr 10 '07 #4
pks00
280 Recognized Expert Contributor
there you are, the moderator also agree's with me so we cant be wrong :)
Apr 10 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP

Hi Mary, long time no see :)
question for you: dont u use currentdb for DAO?

to use the current database for ado, u would use
currentproject.connection

eg

rs.Open "mysql", currentproject.connection, adOpenStatic, adLockPessimistic
Hi nice to see you back. Sorry guys I was tired doing this and since I invariably do DAO rather than ADO myself I wasn't paying attention.

Mary
Apr 10 '07 #6
ADezii
8,834 Recognized Expert Expert
Hi nice to see you back. Sorry guys I was tired doing this and since I invariably do DAO rather than ADO myself I wasn't paying attention.

Mary
No explanation needed, Mary.
Apr 10 '07 #7
GreggaR0und
25 New Member
Thank you, all. Your information helped me to get a little further along. However, now I am getting a run-time error -2147467259 (80004005) when I go to open the database. The text of the error message is: "Database has been placed in a state that prevents opening or locking."

I'm using the With statement, as shown below, so that I can more easily know what properties are being defined.

My ODBC is defined as a SYSTEM DSN and the driver is a Microsoft Access Driver (*.mdb).

With rs
.Source = "tblMy"
.ActiveConnection = "myODBC"
.LockType = adLockPessimistic
.CursorType = adOpenForwardOnly
.Open
End With

Any help is appreciated.

Thanks,
Gregg
Apr 27 '07 #8
pks00
280 Recognized Expert Contributor
You get that error if the database is already open

Close all instances of the db then try running your code
Apr 28 '07 #9
GreggaR0und
25 New Member
Hmmm...that poses a bit of a dilemma. My code is in a VBA Project that is saved in a Module within the .mdb file I'm trying to run. I have to open the database (.mdb file) to access the VB script that I'm trying to execute. I just tried to open another MS Office application (MS Excel) to see if launching Project Explorer would allow it to recognize my Access VBA Project, but it doesn't.

How can I open the source code module without opening the database?

Thanks.
Apr 28 '07 #10
pks00
280 Recognized Expert Contributor
u open the db to run some code. this code, is it reopening same db?
May 2 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3465
by: Sean | last post by:
I'm new to using long raw fields with ASP. I know it would be easier to leave the files on the file system, but the client wants them in the database. Based on what I've read so far, I have used...
0
2767
by: Sue Adams | last post by:
I actually have two issues/questions: I have an autonumber field in an access db table that I grab and later use to update a record in another table withing the same db. The code I use to get...
7
3403
by: Jack | last post by:
Hi, I am trying to test a sql statement in Access which gives me the error as stated in the heading. The sql statement is built as a part of asp login verification, where the userid and password...
2
19295
by: mark | last post by:
I have a form with the following code on Click that calls a procedure passing a date data type value. The field in the table is a date/time data type. What is causing the type mismatch when it...
8
6000
by: aland | last post by:
Hi, I'm hoping someone can help me with this code. I'm getting a 'Type mismatch' error, and I'm not sure why. The SQL works fine in SQL view, so I'm not sure if that's the problem or not. This is...
3
2897
by: amitbadgi | last post by:
I am getting teh following error while converting an asp application to asp.net, Exception Details: System.Runtime.InteropServices.COMException: Type mismatch. Source Error: Line...
6
2363
by: isaac2004 | last post by:
hello i am getting a type mismatch for a page i am trying to write. any help would be great source code <%@ Language=VBScript %> <% Option Explicit %> <!--#include...
1
1746
nurikoAnna
by: nurikoAnna | last post by:
I am having troubled debugging with my codes...It always gets an error "TYPE MISMATCH" Below is my code in my frmApplicantsEntry: ...
1
1577
nurikoAnna
by: nurikoAnna | last post by:
I am having troubled debugging with my codes...It always gets an error "TYPE MISMATCH" Below is my code in my frmApplicantsEntry: __________________________________________________...
0
7175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
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
7553
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...
1
7120
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4754
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3247
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.