error 13 type mismatch

A

Alain

Hi every one,

can anyone help me on this one, I really don't get it

Dim rst As DAO.Database
Dim strSQL As String
Dim intID As Integer

intID = 1
strSQL = "SELECT Sum(AnnualRental) AS SumOfAnnualRental From BasicRental"
& _
" WHERE (DateFrom <= Date() AND DateTo >= Date()) OR (MthToMth =
True)" & _
" GROUP BY IdBranch" & _
" HAVING IdBranch = " & intID & ""

Set rst = CurrentDb.OpenRecordset(strSQL)

The SQL run properly by itself but cannot set it as a recordset

Thanks
 
D

Dirk Goldgar

Alain said:
Hi every one,

can anyone help me on this one, I really don't get it

Dim rst As DAO.Database
Dim strSQL As String
Dim intID As Integer

intID = 1
strSQL = "SELECT Sum(AnnualRental) AS SumOfAnnualRental From
BasicRental"
& _
" WHERE (DateFrom <= Date() AND DateTo >= Date()) OR (MthToMth
=
True)" & _
" GROUP BY IdBranch" & _
" HAVING IdBranch = " & intID & ""

Set rst = CurrentDb.OpenRecordset(strSQL)

The SQL run properly by itself but cannot set it as a recordset


You declared rst to be a Database, not a Recordset:
Dim rst As DAO.Database

Change that to:

Dim rst As DAO.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

Similar Threads


Top