What's wrong with this SELECT statment?

S

Samantha

Hello,
can anyone tell me what's wrong with the following statements? I'm getting
the "Type mismatch" error.

Dim price As Double
Dim model, str As String
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb

str = "SELECT [ML2400-PSMount].[Price] "
str = str & " FROM [ML2400-PSMount]"
str = str & " WHERE [ML2400-PSMount].[Options] = 'F-AC'"
Set rs = db.OpenRecordset(str)
price = rs("Price")

The error is at the "Set rs = db.OpenRecordset(str)" line.
Any help is very much appreciated. thank you very much.
 
D

Douglas J. Steele

I suspect that you've got references set to both ADO and DAO.

When you have both references, you'll find that you'll need to
"disambiguate" certain declarations, because objects with the same names
exist in the 2 models. For example, to ensure that you get a DAO recordset,
you'll need to use Dim rs as DAO.Recordset (to guarantee an ADO recordset,
you'd use Dim rs As ADODB.Recordset)

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top