error 13 type mismatch

  • Thread starter Thread starter Alain
  • Start date Start date
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
 
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
 
Back
Top