By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,248 Members | 1,979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,248 IT Pros & Developers. It's quick & easy.

Get data from previous entry

P: 2
So far, when I scan a product, it records the current time with a Now function. What I need is to know how much time elapsed since my last scan by doing a Datediff function with the previous time recorded. My problem is that I can't manage to get the previous scan time.

I thought of two ways to do this.

1. Previous_scan = DMax("[Hours]", "Data", "Hours < Now()")
This does not work. If I change the criteria to "Hours <= Now()", it gives me the current time as if my function could not find other times recorded than the current time.

2. My second idea was to use a Dlookup and use my autonumber to look for "the current autonumber - 1" in order to get the previous time recorded. But I can't manage to create the variable in order to do this.

Anyone has any idea to solve this ? I've been working on this for 2 days already and it's getting on my nerves.

Thank you so much !
May 29 '12 #1
Share this Question
Share on Google+
2 Replies

P: 2
Here is a part of my actual code.

"Product" is the product number when an item is scanned.
"Hours" is the current time when an item is scanned.
I want "Hours_finish" to be the time of the previous scan.

If Product <> 0 Then
Hours = Now()
End If

If Product <> 0 Then
Previous_scan = DMax("[Hours]", "Data", "Hours < Now()")
End If
May 29 '12 #2

Expert Mod 10K+
P: 12,357
Use the first method. But you need to limit on some sort of product id. What you have there returns the max of all the products. I assume you only want the max of the product you're scanning.
May 29 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.