Hi All,
What I’m trying to do is straight forward.
I’ve a form with multiple textboxes, I validate textbox4 value to be between 2 numbers based on a combolist selection; if it's not then a Msgbox will show up detailing what should be done. I’m using the below afterupdate lines:
Private Sub TextBox4_AfterUpdate()
If DEForm.TextBox4 <> "" Then
DNinterval = Split(DEForm.ComboBox6.Value, " - ")
DNLower = CLng(DNinterval(0))
DNUpper = CLng(DNinterval(1))
If CLng(DEForm.TextBox4) < DNLower Or CLng(DEForm.TextBox4) > DNUpper Then
MsgBox "Please enter an extension between " & DNLower & " and " & DNUpper, vbCritical + vbOKOnly, "Illegal Data Entry"
DEForm.TextBox4.SetFocus
Exit Sub
End If
End If
End Sub
But when I type a number which doesn’t meet my test criterion, I got the error message box but the focus won’t come back to textbox4!
Does anyone have a clue on why this is happening and how can I leave the cursor into textbox4 till the user types a valid entry.
Cheers,
Daniel
Ps: combobox6 will have a value like: 88500 - 88999
What I’m trying to do is straight forward.
I’ve a form with multiple textboxes, I validate textbox4 value to be between 2 numbers based on a combolist selection; if it's not then a Msgbox will show up detailing what should be done. I’m using the below afterupdate lines:
Private Sub TextBox4_AfterUpdate()
If DEForm.TextBox4 <> "" Then
DNinterval = Split(DEForm.ComboBox6.Value, " - ")
DNLower = CLng(DNinterval(0))
DNUpper = CLng(DNinterval(1))
If CLng(DEForm.TextBox4) < DNLower Or CLng(DEForm.TextBox4) > DNUpper Then
MsgBox "Please enter an extension between " & DNLower & " and " & DNUpper, vbCritical + vbOKOnly, "Illegal Data Entry"
DEForm.TextBox4.SetFocus
Exit Sub
End If
End If
End Sub
But when I type a number which doesn’t meet my test criterion, I got the error message box but the focus won’t come back to textbox4!
Does anyone have a clue on why this is happening and how can I leave the cursor into textbox4 till the user types a valid entry.
Cheers,
Daniel
Ps: combobox6 will have a value like: 88500 - 88999