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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenRecordset Type Mismatch Error 2

Status
Not open for further replies.

cmontour

Technical User
Jun 15, 2002
2
US
I am using Access 2000, and calling a form that will (eventually) display a string concatenated summary of a record in a text box.

However when I open the form, I keep getting "Run-time Error '13': Type mismatch", and the "set rs = db.OpenRecordset ...." line below is highlighted. All other code I have commented out to aid in troubleshooting. I've perused the forum and I have already added the Microsoft DAO 3.6 Object Library as a Reference (and ADO is not checked), and restarted Access. I've spent three hours trying to figure this out, I would appreciate any suggestions.

I'm new to writing VB code, but this just feels like there should be a simple cause.

********* BEGIN CODE ***********

Private Sub Form_Open(Cancel As Integer)
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Frame_CircuitID FROM tbCircuits_Frame WHERE Site_Code = '" & Forms!fmSiteDetail.txtSiteCode & "'")
End Sub

********* END CODE *************

If it will help anyone answer my question, the Frame_CircuitID is the primary key in the tbCircuits_Frame table. Site_Code is also a text field in the Frame_CircuitID table. I've also replaced the where clause with a literal value with the same results.
 
Try changing your recordset definition as follows:
[tt]
Dim rs As DAO.Recordset
[/tt]
VB might be confused by the fact that there are two types of recordsets, ADODB.Recordset and DAO.Recordset.
 
Dalchri:

That was the fix! Only four bytes made the fix! Thanks very much. I appreciate you taking the time to respond.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top