This code looks good, do you know for sure which line is producing the error?
Is this code a sub or a function? You could possibly be having trouble with the return value if it is a function.
Main Topics
Browse All TopicsI am using the following code to open a table in an .MDB, but getting error 13 - Type mismatch when the OpenRecordSet function is called.
Dim wrkJet As Workspace
Dim dbOptions As Database
Dim rsOptions As Recordset
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set dbOptions = wrkJet.OpenDatabase("SysOp
Set rsOptions = dbOptions.OpenRecordset("S
Could it have anything to do with the fact I running this code in Module1 as a private function called from Sub_Main, or is there just something wrong with the code?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The error appears upon executing the openrecordset() function when using the debugger. When it error trapping, it jumps to the error handler after that line. It is not a function but a sub called GetOptions(), which is called in the very first line of Sub Main.
Perhaps what is in order here is a second question: how can I be sure the OpenDatabase command actually worked? I was thinking it must have worked, or I would have gotten a different error after the OpenDataBase(). Now I am not so sure...
Strangely, this code works:
Dim wrkJet As Workspace
Dim dbOptions As Database
Dim rsOptions As Recordset
Dim sTableName As String
sTableName = "SystemOptions"
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set dbOptions = wrkJet.OpenDatabase("c:\VB
With dbOptions
.OpenRecordset (sTableName)
End With
Go figure!
Anyway, thanks.
If you have references to two different libraries that have a recordset object, you may have a definition to the wrong one. Say you have ActiveX Data Objects and DAO referenced in your project, then maybe it is trying to use the ADO recordset object. With ADO, you have to Dim with a new, otherwise it is equal nothing (its just a pointer). Maybe in your Dim statement you should specify which types you are using by prefixing them with DAO. Like DAO.Recordset. That may fix your problem.
Later,
Martin
This code *does* work. What confuses me is that VB did not type myRecordset as a Recordset with using the Dim myRecordSet as Recordset statement.... Ah, well.
Dim myRecordset As Variant
Dim wrkJet As Workspace
Dim dbOptions As Database
Dim sTableName As String
sTableName = "SystemOptions"
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set dbOptions = wrkJet.OpenDatabase("c:\VB
Set myRecordset = dbOptions.OpenRecordset(sT
With myRecordset
bPasswordSecurity = ![PasswordSecurity]
bUseageLog = ![UseageLog]
bScanForRequiredFiles = ![ScanForRequiredFiles]
End With
Business Accounts
Answer for Membership
by: DreamingEaglePosted on 1998-10-30 at 14:20:42ID: 1497350
Edited text of question