RE: Check digits



It's probably just my ignorance of the subject matter, but what are you
checking this value against?

You could write a user defined function to determine the checkdigit value,
something like the following, that you could then use in a query

Private Function CheckDigit(strValue as string) as integer

Dim intLoop as integer, lngValue as long
Dim strWeights(10 ) as string
strWeights = split("6,3,7,9,10,5,8,4,2")

if LEN(strValue) <> 9 then
CheckDigit = -1
Exit Function
endif

'Step 1
lngValue = 0
For intLoop = 1 to 9
lngValue = lngValue + val(mid(strValue, intLoop,1)) *
Val(strWeights(intLoop))
Next

'Step 2
lngValue = lngValue - 1
'Steps 3 & 4
CheckDigit = 11 - (lngValue mod 11)

End Function


--
Email address is not valid.
Please reply to newsgroup only.


"DrONDeN" wrote:

I'm trying to implement a Mod 11 data validation into ms access with a
custom weighting. The weighting is as follows:

Position: 9 8 7 6 5 4 3
2 1
Weighting: 6 3 7 9 10 5 8 4
2

Therefore the check digit for number 550015209 would be worked out as
follows:

1. Multiply each number by it's weighing according to position

Weighting: 6 3 7 9 10 5 8 4
2
number: 5 5 0 0 1 5 2
0 9

= 30 15 0 0 10 25 16 0
18

2. Add the products of step 1 together and minus 1

= 114 - 1 = 113

3. Mod 11 the product of step 2

= 113 mod 11 = 3

4. Subtract the product of step 3 from 11

= 11 - 3

5. Check digit = 8 Therefore the new number would be 5500152098

If the check digit = 10 then this is replaced by a hypen eg 552081815-

I would like to implement it so that when the reference number is
entered into a control bound to the reference number field, validation
is performed which checks that the number is valid using method above.
If not, then a message box is displayed warning of error and the text
box is cleared ready for a second attempt.

Is this possible using a query or would I have to use VB. Whichever
way, I would be enourmously grateful of any help pointing me in the
right direction on this one.


.



Relevant Pages

  • Modulus 11 check digit
    ... I'm trying to implement a Mod 11 data validation into ms access with a ... custom weighting. ... Therefore the check digit for number 550015209 would be worked out as ... I would like to implement it so that when the reference number is ...
    (microsoft.public.vb.general.discussion)
  • Check digits
    ... I'm trying to implement a Mod 11 data validation into ms access with a ... custom weighting. ... Therefore the check digit for number 550015209 would be worked out as ... I would like to implement it so that when the reference number is ...
    (microsoft.public.access.formscoding)