Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default ComboBox fails when last item selected first

Hi,
I have a userform combobox that contains 9 listed items. When the user
selects an item the linked cell is displayed in a text area below the
combobox. The code is from a John Walkenbach book and works fine except
when the user opens the userform and immediately selects the last option
from the combobox. If they choose any other option all works fine. Please
could someone advise how to stop the error occurring? -

Private Sub UpdateForm()
ComboBoxTopics.ListIndex = CurrentTopic - 1
Me.Caption = HelpFormCaption & _
" (" & CurrentTopic & " of " & TopicCount & ")"

With LabelText
.Caption = HelpSheet.Cells(CurrentTopic, 2)
.AutoSize = False
.Width = 212
.AutoSize = True
End With
With Frame1
.ScrollHeight = LabelText.Height + 5
.ScrollTop = 1
End With

If CurrentTopic = 1 Then
NextButton.SetFocus
ElseIf CurrentTopic = TopicCount Then
PreviousButton.SetFocus
End If
PreviousButton.Enabled = CurrentTopic < 1
NextButton.Enabled = CurrentTopic < TopicCount
End Sub

--------------------------------------
Thanks,
Mickey


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default ComboBox fails when last item selected first

Hi gareth,
The error is Runtime Error 2110 - Can't move focus to the control because
it is invisible, not enabled or of a type that does not accept the focus.

Mickey


"Gareth" wrote in message
...
This rather depends on what else is going on on the form.

I assume there's a couple of buttons, label and a frame from the code.
What events are there for the combo box?

More importantly - what error message do you get?


MBlake wrote:
Hi,
I have a userform combobox that contains 9 listed items. When the user
selects an item the linked cell is displayed in a text area below the
combobox. The code is from a John Walkenbach book and works fine except
when the user opens the userform and immediately selects the last option
from the combobox. If they choose any other option all works fine.
Please could someone advise how to stop the error occurring? -

Private Sub UpdateForm()
ComboBoxTopics.ListIndex = CurrentTopic - 1
Me.Caption = HelpFormCaption & _
" (" & CurrentTopic & " of " & TopicCount & ")"

With LabelText
.Caption = HelpSheet.Cells(CurrentTopic, 2)
.AutoSize = False
.Width = 212
.AutoSize = True
End With
With Frame1
.ScrollHeight = LabelText.Height + 5
.ScrollTop = 1
End With

If CurrentTopic = 1 Then
NextButton.SetFocus
ElseIf CurrentTopic = TopicCount Then
PreviousButton.SetFocus
End If
PreviousButton.Enabled = CurrentTopic < 1
NextButton.Enabled = CurrentTopic < TopicCount
End Sub

--------------------------------------
Thanks,
Mickey



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default ComboBox fails when last item selected first

Hi Mickey,

I still need a bit more info:

At any stage in your code are you making anything visible/invisible,
enabling/disabling or creating controls?

When the user selects something on the combo box an event is firing.
What is the code for that event?

Gareth



MBlake wrote:
Hi gareth,
The error is Runtime Error 2110 - Can't move focus to the control because
it is invisible, not enabled or of a type that does not accept the focus.

Mickey


"Gareth" wrote in message
...

This rather depends on what else is going on on the form.

I assume there's a couple of buttons, label and a frame from the code.
What events are there for the combo box?

More importantly - what error message do you get?


MBlake wrote:

Hi,
I have a userform combobox that contains 9 listed items. When the user
selects an item the linked cell is displayed in a text area below the
combobox. The code is from a John Walkenbach book and works fine except
when the user opens the userform and immediately selects the last option
from the combobox. If they choose any other option all works fine.
Please could someone advise how to stop the error occurring? -

Private Sub UpdateForm()
ComboBoxTopics.ListIndex = CurrentTopic - 1
Me.Caption = HelpFormCaption & _
" (" & CurrentTopic & " of " & TopicCount & ")"

With LabelText
.Caption = HelpSheet.Cells(CurrentTopic, 2)
.AutoSize = False
.Width = 212
.AutoSize = True
End With
With Frame1
.ScrollHeight = LabelText.Height + 5
.ScrollTop = 1
End With

If CurrentTopic = 1 Then
NextButton.SetFocus
ElseIf CurrentTopic = TopicCount Then
PreviousButton.SetFocus
End If
PreviousButton.Enabled = CurrentTopic < 1
NextButton.Enabled = CurrentTopic < TopicCount
End Sub

--------------------------------------
Thanks,
Mickey




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
vlookup formula fails to return data search item is text Delfina Excel Worksheet Functions 1 November 30th 07 01:01 PM
Filter Copy/Paste Fails - Two Ranges Selected? Craigm[_27_] Excel Programming 4 July 15th 05 04:16 PM
Combobox Add Item MBlake Excel Programming 4 May 2nd 05 04:15 PM
Excel Fails when add-in is selected Ron Excel Worksheet Functions 0 March 14th 05 12:18 AM
ComboBox and select item Soniya Excel Programming 5 August 23rd 03 11:18 AM


All times are GMT +1. The time now is 05:45 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"