The problem is the first IF() condition. You cannot test for NULL like you are trying to do. Look at the following code:
Code:
Sub TestNull()
If 1 = 1 Then
MsgBox "1 equals 1"
End If
If Null = Null Then
MsgBox "True"
Else
MsgBox "Null = Null is false"
End If
If Null <> Null Then
MsgBox "True"
Else
MsgBox "Null <> Null is false"
End If
End Sub
You will never see a message box with TRUE. The only way to test for NULLs is to use the IsNull() function. Try this:
Code:
Private Sub txtHCtrl1Rng_BeforeUpdate(Cancel As Integer)
Dim vTemp
vTemp = Me.txtHCtrl1Rng
If Not IsNull(vTemp) Then
If Int(Val(vTemp)) <> Val(vTemp) Then
MsgBox ("Please enter an integer value")
ElseIf Val(vTemp) < 1 Or Val(vTemp) > 50 Then
MsgBox ("Please enter an integer value between 1 and 50 (inclusive).")
End If
End If
End Sub