Why is a "mismatch" error (13) issued on Openrecordset?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Attempting to add combobox item not in list. Code. used worked in earlier
versions. Using: Set DB=DBENGINE.Workspaces(0).Databases(0). Set
RS=DB.Openrecordset("tablename"). The last statement issues a type mismatch
error (error=13), therefore, not getting to update tablename with newdata
value. I have also tried diffent parameters in the last statement to no
avail. I have also set Limit to list to "No" for the notinlist event to be
called. Would appreciate any help. Thanks
 
Most likely you have references to both the DAO and ActiveX Data Objects
(ADODB) libraries, which both contain objects with the name 'Recordset'. If
you don't specify which type of recordset you want, VBA will use which ever
library appears first in the list of references. The DAO OpenRecordset
method returns a DAO recordset, so if you attempt to assign that to an ADODB
recordset, you get a type mismatch error. To avoid it, 'disambiguate' by
specifying the object library when declaring the recordset variable, e.g.
Dim rst As DAO.Recordset if you want a DAO recordset, and Dim rst As
ADODB.Recordset if you want an ADODB recordset.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
You hit the nail smacks on the head. I have been away too long from this
stuff. I incorporated your suggestion --- and the ole code works again.
Thanks Brenda --- I have my desk full of printed help docs with no mention of
your resolution. Thank you and have a great 2005. Harry
 
Not sure if you will see this since it is an old post BUT I just happened
along this thread and it answers a bug I encountered yesterday!! I did a
work around but now I can use your solution. Thanks so much!
 
Back
Top