Results 1 to 3 of 3
  1. #1
    Join Date
    May 2012

    Unanswered: Get data from previous entry

    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 !

  2. #2
    Join Date
    May 2012
    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

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    jsut get the most recent scan for that product

    dim LastScan as date
    dim elapsedtime as date
    LastScan = DMax("<mycolumn>", "mytable", "myproductID = blah")
    if isnull(lastscan) then
    'this is the first time tis product has been scanned.. what to do
    elapsedtime = now()
    elapsedtime = datediff('h',elapsedtime,now()
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts