Results 1 to 3 of 3

Thread: SIN validation

  1. #1
    Join Date
    Feb 2009

    Unanswered: SIN validation

    Can anyone tell me how to write a SIN validation code to ensure valid SIN number entry?

    First 8 digits: 1 2 3 4 5 6 7 8
    Double the even digits: 4 8 12 16
    Cross-add each digit: 4+8+1+2+1+6=22
    Add the odd digist: 1+3+5+7=16
    Add the results of each: 22+16=38
    Subtract this number from the next highest multiple of 10: 40-38=2

    2 should be the 9th digit. If it doesn't match, then it is an invalid SIN.

    So how do I write this into VBA?

  2. #2
    Join Date
    May 2005
    Nevada, USA
    Provided Answers: 6
    I would create a public function that accepted the number as input, and returned a boolean (true or false). Do your various validations and math and return true/false as appropriate. I suspect you'll make good use of the Mid() function, as well as some others, plus some variables. Here's a primer on functions if you need it:

    Function how-to

  3. #3
    Join Date
    Nov 2007
    Adelaide, South Australia
    What in the world is SIN referring to here?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!

    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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