Results 1 to 3 of 3
  1. #1
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169

    checkers digits

    Friends, I am trying to create a function to generate checkers two digits of a number (eg, 2012001). This function is working, but for some numbers it returns 3 or 4 digits, I would like help from you to identify where the error is.

    Any help is welcome.

    Thank you.

    Public Function GetVerifier(strNumero As String) As String

    Dim N As Integer, P As Integer, S As Integer, D As Double

    For N = 1 To 7
    P = (P + Mid(strNumero, N, 1) * N) Mod 11
    Next

    If P < 3 Then
    P = 0
    End If

    D = strNumero & P


    For N = 1 To 8
    S = (S + Mid(D, N, 1) * (N - 1)) Mod 11
    Next

    If S < 3 Then

    S = 0
    End If



    GetVerifier = P & S

    End Function

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,944
    Why doesn't it work - error message, wrong results, nothing happens?

    Have you step debugged? Follow the code as it executes. Find where execution deviates from expected behavior, fix, repeat. Guidelines in link at bottom of my post.

    Provide sample data and expected results.
    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.

  3. #3
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    June7, I decided, just swapped po mod11 mod10. Thank you so much.

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

Similar Threads

  1. How to grab last two digits from an integer?
    By Robert_PW in forum Queries
    Replies: 4
    Last Post: 03-24-2012, 08:50 PM
  2. Allow only 4 digits in field
    By funkygoorilla in forum Forms
    Replies: 2
    Last Post: 12-01-2011, 09:21 AM
  3. Ignore last two digits in formula
    By anstasija in forum Access
    Replies: 6
    Last Post: 11-02-2010, 08:57 PM
  4. rounding digits
    By giladweil in forum Access
    Replies: 1
    Last Post: 09-01-2010, 03:11 AM
  5. Report query by digits
    By The Phil in forum Reports
    Replies: 4
    Last Post: 04-23-2010, 11:52 AM

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