DUVIDA AO DESENVOLVER UM IF
if bd.getfieldvalue(recdocs,[Ô]tabela_da_base_dados[Ô]) <>0 then
conttabela = 0
do until recdocs.eof
print #f, r1
print #f, r2
print #f, r3
recdocs.movenext
loop
conttabela=conttabela + 1
end if
eu quero que agora no print #f r2,
enquanto as 2 tabelas tem o mesmo id ele imprima o r2 varias vezes consoante o numero de id iguais, senão passa para o r3
rsDoc1.Open [Ô]SELECT * FROM tabela_da_base_dados1 ORDER BY id[Ô], SuaConexao
If rsDoc1.RecordCount <> 0 then
rsDoc1.MoveFirst
Do While Not rsDoc1.EOF
Print #f, r1
rsDoc2.Open [Ô]SELECT * FROM tabela_da_base_dados2 WHERE id_tabela1 = [Ô] & rsDoc1([Ô]id[Ô]) & [Ô] ORDER BY id[Ô], SuaConexao
If rsDoc2.RecordCount <> 0 Then
Do While Not rsDoc2.EOF
Print #f, r2
rsDoc2.MoveNext
Loop
End If
rsDoc2.Close
Print #f, r3
rsDoc1.MoveNext
Loop
End If
a sua ajuda foii boa,mas imprime na r1 e r3 e depois outro id da 2 tabela.
Citação:
BD.RecOpen recDocs, [Ô]SELECT * FROM Fct INNER JOIN FCTLN ON (FCT.FCTID = FCTLN.FCTID) WHERE (Fct.FctData) >=#[Ô] & Format(DataIni.Value, [Ô]m/d/yyyy[Ô]) & _
[Ô]# And (Fct.FctData) <=#[Ô] & Format(DataFim.Value, [Ô]m/d/yyyy[Ô]) & _
[Ô]# And (FctLn.FctLnData) >=#[Ô] & Format(DataIni.Value, [Ô]m/d/yyyy[Ô]) & _
[Ô]# And (FctLn.FctLnData) <=#[Ô] & Format(DataFim.Value, [Ô]m/d/yyyy[Ô]) & [Ô]# ORDER By Fct.FctId, FCTLN.FCTID, Fct.FctNr, Fct.FctData[Ô]
If BD.GETFIELDVALUE(recDocs, [Ô]FCT[Ô]) <> 0 Then
recDocs.MoveFirst
Do While Not recDocs.EOF
Print #f, [Ô]R1[Ô]
BD.RecOpen recDocs2, [Ô]SELECT * FROM Fct INNER JOIN FCTLN ON (FCT.FCTID = FCTLN.FCTID) WHERE (Fct.FctData) >=#[Ô] & Format(DataIni.Value, [Ô]m/d/yyyy[Ô]) & _
[Ô]# And (Fct.FctData) <=#[Ô] & Format(DataFim.Value, [Ô]m/d/yyyy[Ô]) & _
[Ô]# And (FctLn.FctLnData) >=#[Ô] & Format(DataIni.Value, [Ô]m/d/yyyy[Ô]) & _
[Ô]# And (FctLn.FctLnData) <=#[Ô] & Format(DataFim.Value, [Ô]m/d/yyyy[Ô]) & [Ô]# ORDER By Fct.FctId, FctLn.FctId, Fct.FctNr, Fct.FctData, FctLn.FctLnData [Ô]
If BD.GETFIELDVALUE(recDocs2, [Ô]FCTID[Ô]) = BD.GETFIELDVALUE(recDocs, [Ô]FCTID[Ô]) Then
Do While Not recDocs2.EOF
Print #f, [Ô]R2[Ô]
recDocs2.MoveNext
Loop
BD.RecClose recDocs2, True
End If
Print #f, [Ô]R3[Ô]
recDocs.MoveNext
Loop
End If
BD.RecClose recDocs, True
filman, agora ele imprime todos os r2 dentro do 1 ciclo.
ou seja faz me isto:
r1 x
r2 x
r2c
r2c
r2f
r1x
r1c
r2 x
r2c
r2c
r2f
r3c
e eu queria que r2 imprimisse so quando id tabela1 for igual a id da tabela 2