03856me
Active Member
- Joined
- Apr 4, 2008
- Messages
- 297
I have the following code setup in a change event which works perfectly unless the user enters any number preceeded by a zero, like 02 03 etc., then it fires the <= code which isn't correct. Is there some code I can add that would prevent this? I even tried it in the exit event but it worked the same.
There are 3 possible entries that are acceptable
0 should fire first code
-# should fire first code
1-99 should fire second code
Maybe there's a better way to go about this? I am open to any suggestions
There are 3 possible entries that are acceptable
0 should fire first code
-# should fire first code
1-99 should fire second code
Maybe there's a better way to go about this? I am open to any suggestions
Code:
Private Sub txt_dbh_Change()
'check the value is negative or equal to zero
If Me.txt_dbh.Value <= 0 Then
Me.txt_height.Visible = False
Me.lbl_height.Visible = False
Me.lbl_heightNote.Visible = False
Me.txt_1log.Visible = False
Me.lbl_1log.Visible = False
Me.cmd_add.Visible = False
Me.cmd_addNegative.Visible = True
Cancel = True
'check the value is > 0
Else
If Me.txt_dbh.Value > 0 Then
Me.txt_height.Visible = True
Me.lbl_height.Visible = True
Me.lbl_heightNote.Visible = True
Me.txt_1log.Visible = True
Me.lbl_1log.Visible = True
Cancel = True
End If
End If
End Sub