sql - How to access a query with a dependant range of cells -


this function opens connection sql database, collects data , bring , copies cell o6 , onward. have come 2 problems. first want select range of cells in query with. range starts @ i6, , goes cell i"lastrow" last cell contains data want query.

  1. i not know in query:

    where s.cusip = "" 

and 2. tells me there user defined-type not defined.

any appreciated

private sub commandbutton1_click()  call datacollect_alternate ' code  end sub  public sub datacollect_alternate()   dim rs new adodb.recordset  dim cmd new adodb.command  dim i_date string  cmd.activeconnection = openconnectiondpdmview   cmd.commandtext = "select s.description, s.rate coupon, sa.rrb_factor dpdm.security s left join dpdm.security_analytics sa on s.security_id = sa.security_id s.cusip= '" & range("i6").value & "' , sa.as_of_date = trunc(sysdate)"  set rs = cmd.execute 'declare variables' dim lastrow integer 'lastrow = cells(cells.rows.count, "c").end(xlup).row lastrow = range("c65336").end(xlup).row  'copy data excel'     activesheet.range("o6").copyfromrecordset rs  copy_cells (lastrow)  end sub 

for clause try this:

dim swhereclause string dim irow integer  swhereclause = "where s.cusip in ('"  irow=6 lastrow     swhereclause =swhereclause & range("i" & irow).text & "','"       next  debug.print swhereclause ' output immediate window  swhereclause =left(swhereclause ,len(swhereclause)-2) ' remove last comma , quote swhereclause =    swhereclause & ")" ' close in bracket 

so append string swhereclause onto sql query , start debugging!

on line getting error?


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -