UNION DA ERRO....
To tentando fazer a seguinte Consulta:
SQL = "[txt-color=#3333ff]SELECT Saldo, Saldof, Venda, 0 as N_P, 0 as desc, 0 as sub, 0 as valor, "" as parc, 0 as des, 0 as acr, 0 as valorr FROM Caixa WHERE data= #" & Format(Cal.Value, "mm/dd/yyyy") & _
"# UNION SELECT 0 as saldo, 0 as saldof, 0 as venda, N_P, Desc, Sub, Valor, "" as parc, 0 as des, 0 as acr, 0 as valorr FROM C_Ven WHERE Data =#" & Format(Cal.Value, "mm/dd/yyyy") & "# AND Tipo ='AVISTA' " & _
"UNION SELECT 0 as saldo, 0 as saldof, 0 as venda, 0 as N_P, 0 as Desc, 0 as Sub, Valor, Parc, Des, Acr, valorr FROM Notas Where Recto= #" & Format(Cal.Value, "mm/dd/yyyy") & "#"[/txt-color]
tb4.Open SQL, mConn, adOpenStatic, adLockReadOnly
Mas retorna o seguinte erro:
A instrucao sql incluiu uma palavra reservada ou um nome de argumento que esta incorreto ou faltando, ou a pontuação esta incorreta!
Oque ta errado.
SQL = "[txt-color=#3333ff]SELECT Saldo, Saldof, Venda, 0 as N_P, 0 as desc, 0 as sub, 0 as valor, "" as parc, 0 as des, 0 as acr, 0 as valorr FROM Caixa WHERE data= #" & Format(Cal.Value, "mm/dd/yyyy") & _
"# UNION SELECT 0 as saldo, 0 as saldof, 0 as venda, N_P, Desc, Sub, Valor, "" as parc, 0 as des, 0 as acr, 0 as valorr FROM C_Ven WHERE Data =#" & Format(Cal.Value, "mm/dd/yyyy") & "# AND Tipo ='AVISTA' " & _
"UNION SELECT 0 as saldo, 0 as saldof, 0 as venda, 0 as N_P, 0 as Desc, 0 as Sub, Valor, Parc, Des, Acr, valorr FROM Notas Where Recto= #" & Format(Cal.Value, "mm/dd/yyyy") & "#"[/txt-color]
tb4.Open SQL, mConn, adOpenStatic, adLockReadOnly
Mas retorna o seguinte erro:
A instrucao sql incluiu uma palavra reservada ou um nome de argumento que esta incorreto ou faltando, ou a pontuação esta incorreta!
Oque ta errado.
Qdo vc utiliza a clausula union vc deve selecionar sempre os mesmos campos, qdo não for possivel, utilize a palavra NULL.
Tópico encerrado , respostas não são mais permitidas