MS Access Check digit calculation

Discussion in 'Databases' started by KingCobra, Jul 22, 2010.

  1. #1
    I have a MicroSoft Access Database. I need a calculation written (preferably in a query) to create a

    "Weights of (2, 1) Mod 10 Single Digit Summation Check Digit"

    Number that I will then be able to print on my reports.

    MORE EXPLAINED

    mod10 weight 2 check digit for 7 digit number in Excel or MS Access


    I need help creating a mod10 check digit in Excel or MS Access 2007:

    example starting number: 1234567

    Mod10, weight 2 algorithm check digit calculation:

    Calculate: 1*1 + 2*2 + 3*1 + 4*2 + 5*1 + 6*2 + 7*1 = 40

    Check digit: 10  0 = 0 (ten minus last digit of calculation)

    final value: 12345670

    Attached is more information. The client supplies the list of 7 digit numbers.
    PLEASE SEE attachments (a ziped word.doc) file.
     

    Attached Files:

    KingCobra, Jul 22, 2010 IP
  2. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #2
    If you open up a query in Design view and paste every instance of '[input]' with the field of your number, this will generate what you want.

    M10W2: [input] & (10-(Mid([input],1,1)*1+Mid([input],2,1)*2+Mid([input],3,1)*1+Mid([input],4,1)*2+Mid([input],5,1)*1+Mid([input],6,1)*2+Mid([input],7,1)*1) Mod 10) Mod 10
    PHP:
    Here's my assumptions about what you wanted, and its weak points:

    1. The weight number signifies what to multiply every other number by. Further, that number never changes and is always 2.

    2. If this data is stored as a number field every number contains 7 significant digits--there are no leading zeros that get dropped and thus make a number like 785432 show up in your data.

    3. If this data is stored as a string field--every string contains 7 characters, if a number like 785432 is in your data it is represented as '0785432'.

    If any of my assumptions are wrong, let me know. Most likely if they are this will have to become a VBA function.
     
    plog, Jul 22, 2010 IP