combobox setfocus
The cancel will keep the focus in the textbox, so you don't need to use
..setfocus.
And this seemed to work fine for me:
If n Mod 50 < 0 Or n < 50 Or n 7500 Then
Cancel = True
MsgBox "Must be in $50 increments between $50 and $7,500"
cboRPI = ""
End If
=====
Personally, I think a label that would hold the error message is nicer than a
msgbox, but that's not part of your question.
slarbie wrote:
I have a validation routine built for the exit event of my combobox, and it
all works fine. But I'd like the cursor to be blinking in the box again when
all's said and done so the user doesn't have to click back on the control. I
thought the SetFocus, SelStart and SelLength would do that, but no such luck
with the way I have it written. I've also tried various combinations of 1's
and 0's for the SelStart and SelLength settings. What am I missing?
Private Sub cboRPI_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If cboRPI < "" And cboChassis = "blahblah" Then
n = Val(cboRPI)
If n Mod 50 < 0 Or n < 50 Or n 7500 Then
Cancel = True
MsgBox "Must be in $50 increments between $50 and $7,500"
cboRPI = ""
cboRPI.SelLength = 0
cboRPI.SelStart = 0
cboRPI.SetFocus
End If
End If
End Sub
--
Dave Peterson
|