DLookUp field in previous record on a filtered form

G

Guest

I have a filtered form (showing only records associated with a particular
primary key (DocID).
Form Name = frmTaskDateStamp
Table Name = tblTaskDateStamp

This table has a StatID field (autonumbered) and a TimeStamp field.

I want to look up data from the TimeStamp field in the previous record.
Using the following code, I get data from the previous record in the TABLE,
which is not necessarily the previous record in the (filtered) FORM.

=DLookUp("[TimeStamp]","tblTaskDateStamp","[StatID]=Forms![StatusDateStamp]![StatID]-1")

How can I get the DLookUp function to retreive data from the previous record
in the filtered FORM, not the table?
 
S

Steve Schapel

WolfPack,

You will need to include the DocID condition as well as the StatID
condition, for example...

=DLookUp("[TimeStamp]","tblTaskDateStamp","[StatID]=Forms![StatusDateStamp]![StatID]-1
And [DocID]=<something or other>")

By the way, how you have done it makes the assumption that the StatID
will always be sequential with no gaps in the numbering, which you can't
really guarantee with an AutoNumber.
 

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

Top