Hi - I am trying to get to grips with validating an NHS number using the modulus11 algorithm on a form prior to saving the record. So far i have managed to find some code and adapt to what i want to do but cannot get this to work fully - ideally i need this to work on an on_click or on_dirty event.
Please help? I am going greyer by the hour trying to implement this.
Could someone please take a look at the code and advise how i would implement this to an on_click or dirty?
Many Thanks - Ian
Please help? I am going greyer by the hour trying to implement this.
Could someone please take a look at the code and advise how i would implement this to an on_click or dirty?
Many Thanks - Ian
Code:
Public Function NHS_Number_Check (ByVal DigitType As Byte, ByVal txtNHSNumber As String) As String
Dim tmpNumber, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Asum, Bsum, Csum
tmpNumber = Trim(txtNHSNumber)
A1 = Mid(tmpNumber, 1, 1) * 10
A2 = Mid(tmpNumber, 2, 1) * 9
A3 = Mid(tmpNumber, 3, 1) * 8
A4 = Mid(tmpNumber, 4, 1) * 7
A5 = Mid(tmpNumber, 5, 1) * 6
A6 = Mid(tmpNumber, 6, 1) * 5
A7 = Mid(tmpNumber, 7, 1) * 4
A8 = Mid(tmpNumber, 8, 1) * 3
A9 = Mid(tmpNumber, 9, 1) * 2
A10 = Mid(tmpNumber, 10, 1) * 1
Asum = A1 + A2 + A3 + A4 + A5 + A6 + A7 + A8 + A9 + A10
Bsum = Asum Mod 11 'Reminder
Csum = 11 - Bsum
If Csum = 0 Then
MsgBox ("Valid NHS Number")
Else
MsgBox ("Invalid NHS Number")
End If
End Function