Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Help with SetFocus required please

I have a combobox in a userform and wish to prevent the leaving the value
blank.
I have used the following code

If ComboBox1.listIndex = -1 Then
Msgbox "Please select a value"
Combobox1.SetFocus
End If

It doesn't work - the focus moves to the next control

Why is this ?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Help with SetFocus required please

I should have specified that I have used the code in the Exit Procedure as
follows

Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

If ComboBox1.listIndex = -1 Then
Msgbox "Please select a value"
ComboBox1.SetFocus
End If

End Sub


Regards & TIA



"Jim @Eclipse.co.uk" <JimBurton<NOSPAM wrote in message
...
I have a combobox in a userform and wish to prevent the leaving the value
blank.
I have used the following code

If ComboBox1.listIndex = -1 Then
Msgbox "Please select a value"
Combobox1.SetFocus
End If

It doesn't work - the focus moves to the next control

Why is this ?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Help with SetFocus required please

Instead of ComboBox1.SetFocus, try using Cancel = True instead.

Rick


"Jim @Eclipse.co.uk" <JimBurton<NOSPAM wrote in message
...
I should have specified that I have used the code in the Exit Procedure as
follows

Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

If ComboBox1.listIndex = -1 Then
Msgbox "Please select a value"
ComboBox1.SetFocus
End If

End Sub


Regards & TIA



"Jim @Eclipse.co.uk" <JimBurton<NOSPAM wrote in message
...
I have a combobox in a userform and wish to prevent the leaving the value
blank.
I have used the following code

If ComboBox1.listIndex = -1 Then
Msgbox "Please select a value"
Combobox1.SetFocus
End If

It doesn't work - the focus moves to the next control

Why is this ?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Help with SetFocus required please

Thank you Rick - works just as I need

"Rick Rothstein (MVP - VB)" wrote in
message ...
Instead of ComboBox1.SetFocus, try using Cancel = True instead.

Rick


"Jim @Eclipse.co.uk" <JimBurton<NOSPAM wrote in message
...
I should have specified that I have used the code in the Exit Procedure as
follows

Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

If ComboBox1.listIndex = -1 Then
Msgbox "Please select a value"
ComboBox1.SetFocus
End If

End Sub


Regards & TIA



"Jim @Eclipse.co.uk" <JimBurton<NOSPAM wrote in message
...
I have a combobox in a userform and wish to prevent the leaving the value
blank.
I have used the following code

If ComboBox1.listIndex = -1 Then
Msgbox "Please select a value"
Combobox1.SetFocus
End If

It doesn't work - the focus moves to the next control

Why is this ?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setfocus Problem Craig M Excel Programming 9 March 3rd 07 08:29 PM
SetFocus? plh Excel Programming 1 May 1st 06 03:01 AM
SetFocus problem JH Excel Programming 1 April 18th 05 03:55 PM
setfocus Dean Reardon Excel Programming 2 December 15th 04 12:18 PM
setfocus after a msgbox simpleMod[_3_] Excel Programming 1 October 26th 04 07:25 PM


All times are GMT +1. The time now is 07:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"