Results 1 to 3 of 3
  1. #1
    athyeh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    170

    Counter that ignores duplicates?

    Have the code below behind a form that I am using to count how many barcodes an operator scans in. Is there a way to for this counter to count duplicate values as 1?

    So if I scan in barcode: 10001, 10001, 10001, I only get credit for 1?

    Thanks!

    If Hour(Now()) > Nz(Me.tbxHour, -1) Then


    Me.tbxCount = 0
    Me.Goal = 35
    Me.tbxHour = Hour(Now())
    End If
    Me.tbxCount = Me.tbxCount + 1

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    You need to query the table that stores the barcode scan result (i.e. 10001) via a Totals query. You can then place you result into your Me.tbxCount without the Me.tbxCount +1.

    You only want to count barcode scan results that match your current session, whatever that criteria may be. Maybe, WHERE UserID AND ScannerSN AND ProjectNum or something along those lines.
    Last edited by ItsMe; 09-20-2013 at 01:20 PM. Reason: Removed DCOUNT comment

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Try:

    Dim strBarCode As String 'delared in module header, not within the procedure

    ______________________

    Sub ...
    If Hour(Now()) > Nz(Me.tbxHour, -1) Then
    Me.tbxCount = 0
    Me.Goal = 35
    Me.tbxHour = Hour(Now())
    End If
    If strBarCode <> Me.tbxBarCode Then
    Me.tbxCount = Me.tbxCount + 1
    strBarCode = Me.tbxBarCode
    End If
    ...
    End Sub


    This only works if the duplicate barcodes are scanned sequentially. If a barcode is scanned again after other barcodes, it will be counted.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 02-16-2013, 07:57 AM
  2. Access Ignores Default Image Viewer
    By ianmalik in forum Access
    Replies: 2
    Last Post: 01-27-2013, 05:42 PM
  3. Counter
    By Skroof in forum Access
    Replies: 3
    Last Post: 05-14-2012, 08:25 AM
  4. Need counter to print
    By miziri in forum Access
    Replies: 1
    Last Post: 05-11-2011, 02:07 AM
  5. lap Counter
    By challenger in forum Access
    Replies: 4
    Last Post: 07-06-2010, 02:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums