SQL COUNT request in VBA

  • Thread starter Thread starter Bataille Jean-Paul
  • Start date Start date
B

Bataille Jean-Paul

The error number is 13 : compabilité de type that i translate in TYPE
INCOMPATIBILITY
on the line
Set RST = CurrentDb.OpenRecordset(strSQL)
 
Let me guess (since you didn't say, and I forgot to ask).

You're using Access 2000 or newer.

The code you're trying to use is DAO, whereas, by default, Access 2000 and
newer use ADO.

With any code module open, select Tools | References from the menu bar,
scroll through the list of available references until you find the one for
Microsoft DAO 3.6 Object Library, and select it. If you're not going to be
using ADO, uncheck the reference to Microsoft ActiveX Data Objects 2.1
Library

If 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 RST as DAO.Recordset (to guarantee an ADO recordset, you'd use Dim
RST 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
 
Yeah!!!

By using MS DAO 3.6 i've solve the problem,
now i have to replace 109 who is a possible value in a combobox by the name
of the combobox named "SAP in the form "F_DA"


JP
'THE SQL REQUEST
strSQL = "SELECT Count(Clé_Contrat) AS Nbr " & _
"FROM R_Contrat_Fluide_finale " & _
"WHERE (((R_Contrat_Fluide_finale.Clé2_SAP)=109));"
 
Back
Top