Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch Error

Status
Not open for further replies.

pvwdr

MIS
Jan 16, 2003
38
0
0
US
I am sure this is something simple but this code goves me runtime error 13, type mismatch:

Dim CurDB
Dim Rs As Recordset
Dim Ctrl As Control
Dim Entry As Variant

Set CurDB = CurrentDb()
Set Rs = CurDB.OpenRecordset("tblTemp_Grp") **
Set Ctrl = Me![lstAvailable]

** This is where it errors, all tables are in the same db as code, using Access 2002 ... any help would be appreciated.

Thank you,
Bill
 
Looks like an ADO/DAO mismatch. In Access 2002, I believe the default data model is ADO, therefore Rs is, by default, assumed to the ADO type recordset. As far as I know, the CurrentDb function returns an object type of DAO.Database, which I'm guessing is why you declared CurDB as a variant because the compiler would not accept Dim CurDB as Database. The Database type only exists in DAO. In any event, the .OpenRecordset method of that object returns a DAO type recordset which you are attempting to assign to an ADO type recordset, hence, type mismatch.

You should do several things. First, include into the project a reference to the lastest DAO object library. Second, declare CurDB as DAO.Database rather than variant, and finally, declare Rs as DAO.Recordset.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Explicitly declare your database and recordset objects as DAO like this
Code:
Dim CurDB As DAO.Database
Dim Rs As DAO.Recordset
If you have a reference to the ADODB library then Access may be defaulting to ADODB.Recordset which has a different syntax.
 
Thanks, that seems logical ... when I did it I got an error stating that the database has been placed in a state that prevents it from being opened or unlocked ... I am not sure why
 
Someone else has the database open

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
That isn't the case, it is on my pc with no other access to it I wish it were that, I could keep people off
 
You may have an .ldb file that has stuck open. Close your app and then find it in Windows Explorer. See if there are any .ldb files open associated with that Db. If there are you can just try rebooting your machine. That should get rid of it. Or you can just try deleting it which sometimes works and sometimes doesn't.

Paul
 
You alone can have both copies open, with one copy locking out the other. Shut down all copies that you have open, and you might want to check through the Task Manager to insure that no other copies of MSAccess are open (shut them down if they are), and then try again.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top