Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Dave, I appreciate the quick response. That didn't work for me either
- but it helps just to know that it did work for you. Makes me think my problem might instead be due to there being no items in the combobox list. I'll go and try just creating a single "" item. I know I know - why am I using a combobox for this? Long story, but there really is a reason for it - I won't bore you with the details - most of the time it actually has list items... "Dave Peterson" wrote: 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I tried it again with no items in the combobox list (I used .clear to clear it).
And it still worked ok. I was left with a flashing I-beam cursor in the combobox input area. ps. I used xl2003 for my tests. slarbie wrote: Thanks Dave, I appreciate the quick response. That didn't work for me either - but it helps just to know that it did work for you. Makes me think my problem might instead be due to there being no items in the combobox list. I'll go and try just creating a single "" item. I know I know - why am I using a combobox for this? Long story, but there really is a reason for it - I won't bore you with the details - most of the time it actually has list items... "Dave Peterson" wrote: 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 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
setfocus | Excel Programming | |||
SetFocus? | Excel Programming | |||
SetFocus from ComboBox to Calendar gives Run-time error | Excel Programming | |||
setfocus | Excel Programming | |||
How Do I Get SetFocus On A ComboBox In A Frame? | Excel Programming |