recordset problem

  • Thread starter Thread starter Gurtz
  • Start date Start date
G

Gurtz

Hello,

I get a "Type mismatch." error (run-time error 13) when I
execute the following code:

Private Sub Form_Open(Cancel As Integer)
Dim tmpRec As Recordset
Dim tmpDB As Database
Set tmpDB = CurrentDb

Set tmpRec = tmpDB.OpenRecordset("SELECT Pic FROM
Players WHERE PlayerIndex = " & Me.PlayerIndex)
Me.PlayerPic.Picture = tmpRec.Fields(0)
End Sub

The error occurs when OpenRecordset is called..
I can't figure this one out. Can anybody help?

Thanks a lot,
Gurtz
[email = no $]
 
There could be two things;

a. If the PlayerIndex is a string data type, you will need quotes around
your criteria, eg:
Set tmpRec = tmpDB.OpenRecordset("SELECT ... WHERE PlayerIndex = '" &
Me.PlayerIndex & "'")

b. Check your references and see what version of DAO you are using... The
old versions sometimes give an error 13 when assigning an 'OpenRecordset' to
a Recordset object... You should be using at least Microsoft DAO 3.6 (or
3.51)...
 
I get a "Type mismatch." error (run-time error 13) when I
execute the following code:

Private Sub Form_Open(Cancel As Integer)
Dim tmpRec As Recordset
Dim tmpDB As Database
Set tmpDB = CurrentDb

Set tmpRec = tmpDB.OpenRecordset("SELECT Pic FROM
Players WHERE PlayerIndex = " & Me.PlayerIndex)
Me.PlayerPic.Picture = tmpRec.Fields(0)
End Sub

The error occurs when OpenRecordset is called..
I can't figure this one out. Can anybody help?

Are you using Access 2000, or later? If so, you probably have a reference to the
DAO Object Library that is below a reference to the ADO library in the
references list. See the following for more information:

PRB: Error 13 Type Mismatch Error on DAO OpenRecordset Method
http://support.microsoft.com/default.aspx?scid=kb;en-us;181542
 
Have you verified that the query string actually returns data?
Do you have DAO 3.6 checked as a reference?
 
Thank you all for your assistance, you've been very
helpful.

I moved the DAO 3.6 reference to a higher priority, and it
appears to have solved my problem. Thanks very much!

Gurtz
[email = no $]
 
Thank you all for your assistance, you've been very
helpful.

I moved the DAO 3.6 reference to a higher priority, and it
appears to have solved my problem. Thanks very much!

Thanks for getting back to us with your solution.

:-)
 
Back
Top