Hi Guys,
I need some more advise please. I am trying to set rules on a text box. Basically I do not want to allow anything other than the numbers 7 to 13 to be accepted. This works to a degree but fails it somebody choose back space or anything other than just type in a number. Ideally i would like it to check the txt box rules once the user has pressed tab or the return key. As I cannot see those options available I used the change sub.
Is it possible to check the contents of the txt box when a user presses tab or return?
Thanks your help is much appreciated.
Private Sub txtreg_Change()
If txtreg.Text < 7 Or txtreg.Text > 13 Then MsgBox "Please type in a current Year": txtreg.Text = "": txtreg.SetFocus: GoTo lp
cmbcredit.Enabled = True
lp:
End Sub
I need some more advise please. I am trying to set rules on a text box. Basically I do not want to allow anything other than the numbers 7 to 13 to be accepted. This works to a degree but fails it somebody choose back space or anything other than just type in a number. Ideally i would like it to check the txt box rules once the user has pressed tab or the return key. As I cannot see those options available I used the change sub.
Is it possible to check the contents of the txt box when a user presses tab or return?
Thanks your help is much appreciated.
Private Sub txtreg_Change()
If txtreg.Text < 7 Or txtreg.Text > 13 Then MsgBox "Please type in a current Year": txtreg.Text = "": txtreg.SetFocus: GoTo lp
cmbcredit.Enabled = True
lp:
End Sub