B
blackcat
I have the following code which checks the ISBN check digit to ensure a
correct ISBN no is enter for a product. This works fine, however, if the
user enters the field and then decideds not to enter an isbn no, i get the
'Invalid Use of Null' error message which will not go away and even takes the
user into the code, which i don't want. Could anyone please tell me how to
stop this happening, i've tried setting the strnumer as variant but this
doesn't work.
Private Sub LinkISBN_Exit(Cancel As Integer)
varMultiplier = Array(Null, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3)
'Dim strnumber As Variant
strnumber = [LinkISBN]
'strnumber = format(dwisbn, "000000000")
dwchecksum = 0
total = 0
'checkno = CInt(Mid(strnumber, 10, 1))
checkno = Mid(strnumber, 13, 1)
msg = "Incorrect ISBN Please Re-Enter"
For p = 1 To Len(strnumber)
'wdigit = CInt(Mid(strnumber, p, 1))
wdigit = Mid(strnumber, p, 1)
If p >= 1 And p <= 12 Then
dwchecksum = wdigit * varMultiplier(p)
total = total + dwchecksum
End If
'If p = 10 And [wdigit] <> "X" Then
'dwchecksum = wdigit * varMultiplier(p)
'total = total + dwchecksum
'End If
[tot] = total
Next p
[modfig] = [tot] Mod 10
[check] = 10 - [modfig]
If [modfig] = 0 Then
[check] = 0
End If
If [modfig] = 1 Then
[check] = "X"
End If
check = LTrim(check)
If check <> checkno Then
MsgBox (msg)
End If
End Sub
correct ISBN no is enter for a product. This works fine, however, if the
user enters the field and then decideds not to enter an isbn no, i get the
'Invalid Use of Null' error message which will not go away and even takes the
user into the code, which i don't want. Could anyone please tell me how to
stop this happening, i've tried setting the strnumer as variant but this
doesn't work.
Private Sub LinkISBN_Exit(Cancel As Integer)
varMultiplier = Array(Null, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3)
'Dim strnumber As Variant
strnumber = [LinkISBN]
'strnumber = format(dwisbn, "000000000")
dwchecksum = 0
total = 0
'checkno = CInt(Mid(strnumber, 10, 1))
checkno = Mid(strnumber, 13, 1)
msg = "Incorrect ISBN Please Re-Enter"
For p = 1 To Len(strnumber)
'wdigit = CInt(Mid(strnumber, p, 1))
wdigit = Mid(strnumber, p, 1)
If p >= 1 And p <= 12 Then
dwchecksum = wdigit * varMultiplier(p)
total = total + dwchecksum
End If
'If p = 10 And [wdigit] <> "X" Then
'dwchecksum = wdigit * varMultiplier(p)
'total = total + dwchecksum
'End If
[tot] = total
Next p
[modfig] = [tot] Mod 10
[check] = 10 - [modfig]
If [modfig] = 0 Then
[check] = 0
End If
If [modfig] = 1 Then
[check] = "X"
End If
check = LTrim(check)
If check <> checkno Then
MsgBox (msg)
End If
End Sub