Changing a SQL Instuction

G

gatarossi

Dear all,

I'm trying to do a consult in access from excel, but I don´t know how
to change the information of the field lote_contabil ('RT0101' AS
Expr1). This is a text that I put in my INSERT INTO consult, but I
need to connect others informations; in a excel formula it looks like:

="RT0"&razao_contabil.ano_mes&"0"&razao_contabil.codigo_cenario

But how can I adapt it in this SQL instruction?

strSQL = "INSERT INTO razao_contabil ( codigo_conta_contabil,
codigo_centro_custo, codigo_cenario, orc_real, ano_mes, lote_contabil,
historico_lancamento, valor_transacao ) "
strSQL = strSQL & "SELECT rateio.codigo_conta_contabil_destino,
rateio.codigo_centro_custo_destino, razao_contabil.codigo_cenario,
razao_contabil.orc_real, razao_contabil.ano_mes, 'RT0101' AS Expr1,
'MOVTO. RATEIO' AS Expr2,
([razao_contabil.valor_transacao]*[rateio.percentual_alocacao])*-1 AS
valor_rateio "
strSQL = strSQL & "FROM razao_contabil INNER JOIN rateio "
strSQL = strSQL & "ON (razao_contabil.codigo_centro_custo =
rateio.codigo_centro_custo_origem) AND
(razao_contabil.codigo_conta_contabil =
rateio.codigo_conta_contabil_origem) "
strSQL = strSQL & "WHERE ((razao_contabil.orc_real)='orc') AND
((rateio.codigo_cenario)='1') ;"

Thanks a lot!!!

André.
 

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

Top