How to read the value of a field in the previous record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to calculate a field based on the value of the the same field of the
previous record. Can anybody suggest a way to read the value of a certain
field of the previous record?
Thanks in advance

Michalis J
 
Hi, Michalis.
Can anybody suggest a way to read the value of a certain
field of the previous record?

Please see the following Web page for the KB article, which supplies sample
VBA code and query expressions which return the value of a field in the
previous record:

http://support.microsoft.com/default.aspx?id=210504

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Michalis J. said:
I need to calculate a field based on the value of the the same field of the
previous record. Can anybody suggest a way to read the value of a certain
field of the previous record?
Thanks in advance

Michalis J

Hi Michalis J,

you can do it by this code in your form on the current event :

Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.bookMark = Me.bookMark
rst.MovePrevious
Me.recPrec = rst.Fields("id_data_fattura").Value

Set rst = Nothing

Exit_DelCurrentRecord_Click:
Exit Sub

errori:
Resume Exit_DelCurrentRecord_Click

Well : me.recPrev is the name of your textb form that has the vlaue of the
previous record. The name of the record is id_data_fattura.
You must get the error because before of the first record there isn't
nothing :-)

Ciao, Sandro

HTH
 
Thank you both very much.

'69 Camaro said:
Hi, Michalis.


Please see the following Web page for the KB article, which supplies sample
VBA code and query expressions which return the value of a field in the
previous record:

http://support.microsoft.com/default.aspx?id=210504

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Back
Top