Getting the next record (VBA)

  • Thread starter Thread starter Rodolfo Fontes
  • Start date Start date
R

Rodolfo Fontes

Hi group,

How can I get the next value of a querie?
For example, I can use "temp = rs_NFS!DT_Emissao" to get the DT_Emissao from
the current record, but i want just to get the next value, not "walk" on it.
Below an example:

Dim db_NFS As Database, rs_NFS As Recordset
Set db_NFS = CurrentDb
Set rs_NFS = dbs_produto.OpenRecordset("SELECT [T NF_S].DT_Emissao, [T
NF_S_Det].CodProd, [T NF_S_Det].Qtd_NF, [T NF_S_Det].Valor_NF " _
& " FROM [T NF_S] INNER JOIN [T NF_S_Det] ON [T NF_S].Cod_NF_S = [T
NF_S_Det].Cod_NF_S " _
& " WHERE ((([T NF_S].DT_Emissao) Is Not Null) And (([T
NF_S].Processada) = -1) And (([T NF_S].Cancelada) = 0)) " _
& " ORDER BY [T NF_S].DT_Emissao, [T NF_S_Det].CodProd;")

Thanks,
Rodolfo Fontes
 
Hi Rodolfo,

Not sure what you mean by "walk", but to get to the next record in a
Recordset, it's simply rs_NFS.MoveNext. The fields will then correspond to
the values in the next record retrieved by the query (unless, of course,
there aren't any more, in which case you won't be able to refer to the
fields and the condition rs_NFS.EOF will be True instead of False)
 

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

Similar Threads

access is rounding a value 9
Count on the page 1
getting long value 2
Sintax error 1
Random Top 10 percent of groups 6
vba Function code 1
form criteria 4
Access References 11

Back
Top