R
RobUCSD via AccessMonster.com
I want to use the following check sum routine to check for the validity of
newly input medical record numbers (MRN). Problem is that some of the MRN's
have leading zero's so the routine won't work. If I change the MRN field to a
txt field, then it doesn't work at all.
Is there anyway to tell access not to cut off the zero's? Thanks for your
help. Robert
*******************************************************************************************************************
Private Sub MRN_BeforeUpdate(Cancel As Integer)
If Len(MRN) <> 8 Then
MsgBox ("Please enter the full 8 digit Medical Record Number")
Else
If Len(MRN) = 8 Then
Dim MR(8), I, J, K, L, Odd, Even As Integer
For I = 1 To 8
MR(I) = Val(Mid(MRN, I, 1))
Next I
Even = MR(2) + MR(4) + MR(6)
Odd = 2 * (Val(Str(MR(1)) & Str(MR(3)) & Str(MR(5)) & Str(MR(7))))
J = Len(Str(Odd))
For I = 1 To J
K = K + Val(Mid(Str(Odd), I, 1))
Next I
K = K + Even
L = 10 * (Int(K / 10) + 1)
If MR(8) <> L - K Then
If L - K <> 10 Then MsgBox ("That Medical Record Number is NOT
valid!")
End If
Else
MsgBox ("Please enter the full 8 digit Medical Record Number")
End If
End If
End Sub
******************************************************************************************************
newly input medical record numbers (MRN). Problem is that some of the MRN's
have leading zero's so the routine won't work. If I change the MRN field to a
txt field, then it doesn't work at all.
Is there anyway to tell access not to cut off the zero's? Thanks for your
help. Robert
*******************************************************************************************************************
Private Sub MRN_BeforeUpdate(Cancel As Integer)
If Len(MRN) <> 8 Then
MsgBox ("Please enter the full 8 digit Medical Record Number")
Else
If Len(MRN) = 8 Then
Dim MR(8), I, J, K, L, Odd, Even As Integer
For I = 1 To 8
MR(I) = Val(Mid(MRN, I, 1))
Next I
Even = MR(2) + MR(4) + MR(6)
Odd = 2 * (Val(Str(MR(1)) & Str(MR(3)) & Str(MR(5)) & Str(MR(7))))
J = Len(Str(Odd))
For I = 1 To J
K = K + Val(Mid(Str(Odd), I, 1))
Next I
K = K + Even
L = 10 * (Int(K / 10) + 1)
If MR(8) <> L - K Then
If L - K <> 10 Then MsgBox ("That Medical Record Number is NOT
valid!")
End If
Else
MsgBox ("Please enter the full 8 digit Medical Record Number")
End If
End If
End Sub
******************************************************************************************************