I have two tables, tab_prefixo
has number of prefixo
and gerente
responsible (important data), and in the other one (table tab_valores
), it also displays prefixo
, nome
, valor
and data
.
I want, with command prefixo.movefirst
, to get the first prefixo
from the tab_prefixo
table and look for the lines tab_valores
in the valor
table and copy those data to a new table, the prefixo
table, which will contain tab_correio
, prefixo
, nome
, valor
and data
, and forward mail to that prefix. Then, with gerente
command, it passes to the second prefixo.movenext
of the prefixo
table, and again look for the data that contains the same tab_prefixo
in the prefixo
table and copy the required data into the tab_valores
, and send mail for such a prefix .. and so on.
I'm just able to query with the commands below:
Dim db As Database
Set db = CurrentDb
Dim Linha As Integer
Set prefixo = db.OpenRecordset("select * from Tab_prefixo order by prefixo")
Set valores = db.OpenRecordset("select * from tab_valores")
Set correio = db.OpenRecordset("tab_correio")
prefixo.MoveFirst
Do While Not prefixo.EOF
If agencias!CODPREF = divida!agencia Then
correio.AddNew
correio!prefixo = divida!prefixo
correio!nome = divida!nome
correio!valor = divida!valor
correio!Data = divida!Data
correio!GERENTE = agencias!GERENTE
correio.Update
End If
agencias.MoveNext
Loop
'CurrentDb.Execute "DELETE * FROM tab_correio"
End Sub
I actually know that my command is incomplete .. something is missing, and there must be something out of place, but I packed it here.
If someone can help me, thank you very much, because I can not go on .. suddenly I am missing a tab_correio
, I am trying everything, but not walking ..