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

Type mismatch from SQL statement inside VBA

Status
Not open for further replies.

DRH192

Programmer
Apr 25, 2005
96
GB
Can anyone see why the following line

Set Rst = Dbs.OpenRecordset("SELECT TOP 5 tblInvestigation.InvestigationID, tblInvestigation.Agent, tblInvestigation.MailType FROM tblInvestigation WHERE ((tblInvestigation.MailType)= 10);")

would return the error code 13 "Type Mismatch"?

I copied this SQL statement into a query and it works as I would expect pulling back the top 5 records.

Cheers
 
is rst ado or dao?
and what is dbs set to?

--------------------
Procrastinate Now!
 
Is the data type of "MailType" Text rather than Number? If so perhaps you need
Code:
WHERE ((tblInvestigation.MailType)= [COLOR=red]'[/color]10[COLOR=red]'[/color]);")

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
hopefully you omitted to post the following ?
Dim dbs As Database
Dim rst As DAO.Recordset
Set dbs = CurrentDB

And in the VBE menu Tools -> References ... you have the Microsoft DAO 3.# Object Library ticked ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top