The querie is
SELECT Format("54","00") AS 01_Tipo, IIf([CNPJ] Is Not
Null,Format([CNPJ],"00000000000000"),Format([CPF],"00000000000000")) AS
02_CNPJ, Format(1,"00") AS 03_Modelo,
Replace(Format(Left([Serie],3),"@@@")," ","0") AS 04_Serie,
Format([Numero_NF],"000000") AS 05_NumNF, Format([CFOP],"0000") AS 06_CFOP,
IIf([Cod_Sit_Trib] Is Null,[CodSitTrib],[Cod_Sit_Trib]) AS 07_CST,
Format([Apoio_sintegra],"000") AS 08_NumItem, Format(Left([T
NF_E_Det].[Part#F],14),"General Number") AS [09_Part#F],
Format([Qtd_NF],"00000000000") AS 10_Qtd, Format([Valor_NF],"0000000000") &
"00" AS 11_Valor_NF, "000000000000" AS 12_V_DESC,
Format([Valor_NF],"0000000000") & "00" AS 13_BASE_ICMS, "000000000000" AS
14_BASE_ICMS_CST,
Format(Round(Round([Valor_NF]*[Qtd_NF],2)*([IPI_NF]/100),2),"0000000000") &
"00" AS 15_VL_TOT_IPI, Format([ICMS_NF],"00") & "00" AS 16_AL_ICMS, [T
NF_E].DT_Emissao
FROM [T NatOper] INNER JOIN ([T CliFor] INNER JOIN ([T NF_E] INNER JOIN ([T
NF_E_Det] INNER JOIN [T Produtos_Itens] ON [T NF_E_Det].CodProd = [T
Produtos_Itens].CodProd) ON [T NF_E].Cod_NF_E = [T NF_E_Det].Cod_NF_E) ON [T
CliFor].CodCliFor = [T NF_E].CodCliFor_Fat) ON [T NatOper].CodNatOper = [T
NF_E].CodNatOper
WHERE ((([T NF_E].DT_Emissao) Between [Formulários]![F Sintegra]![txtDataI]
And [Formulários]![F Sintegra]![txtDataF]))
ORDER BY Format([Numero_NF],"000000"), Format([Apoio_sintegra],"000");
It's not a good solution...
But copying it to a table, then exporting works fine.
Is there anything wrong with this querie?
Thanks,
Rodolfo Fontes