View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
barry barry is offline
external usenet poster
 
Posts: 116
Default VBA excel - problem with having clause in sql with adodb.connectio

Hi Kiran

The having clause should be at the end

Select ...
From ...
Group By ...
Having ...

Try reorganising your query so that it is this way around. Not sure about
your error though, souunds like there may be something else going on as well
but that should be a start.

Thanks

Barry



"ukp9999" wrote:


Hi

i need a help on the following error

i am getting error in VBA excel when i am using having clause in the
sql.
i used adodb.connection and adodb.recordset.

my problem is, i need to check duplicates in the oracle table.
so i used the sql statement as follows

select count(*) from table-1
having count(*) 1
group by field-1,field-2,field-3.

and string the count in a variable.

var-1 = rs.fields(0).

when i execute that i am getting error as runtime error : 3021
and here is the description

" Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires current record"

here is my code

strsql = "select name,product,product_number,begin_date,end_date from
product_lisence_info" _
& " having count(*) 1 " _
& " group by
name,product,product_number,begin_date,end_date "


rs1.Open strsql, con1, adOpenKeyset

dupli = rs1.Fields(0)


rs1.close


thanks

Kiran


--
ukp9999
------------------------------------------------------------------------
ukp9999's Profile: http://www.excelforum.com/member.php...o&userid=28853
View this thread: http://www.excelforum.com/showthread...hreadid=486019