Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default ComboBox Problem

I have a form that on loading Sets Focus to the only combobox on the
form. THe combobox initially starts out either blank or with text, and
always has the same list of values.

However, when the combox box starts out empty, there is no cursor inside
of it so I can't just start typing text. How do I fix this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default ComboBox Problem

I put a combobox on a userform with several controls. The combobox had no
data in the list. I set the TabIndex property to 0 and when I showed the
form, the cursor was blinking in the combobox. If you are using some other
method, don't.

--
Regards,
Tom Ogilvy

"R Avery" wrote in message
...
I have a form that on loading Sets Focus to the only combobox on the
form. THe combobox initially starts out either blank or with text, and
always has the same list of values.

However, when the combox box starts out empty, there is no cursor inside
of it so I can't just start typing text. How do I fix this?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default ComboBox Problem

I figured out the problem, but it sure took a while. I tried your
suggestion, and it worked, for the first time only. Any subsequent
..Show's of the form did not have the cursor in the combobox. However,
when I tried to replicate my experience in a new simple form, I got the
same behavior.

I solved this for the simple form by doing an Unload Form1 before
showing the form each time, and it worked perfectly. However, that did
not work for my form.

It turns out that I had disabled the form QueryClose event by always
setting the Cancel parameter to TRUE. After removing that code, the
form was properly unloaded from memory, and when shown again, the cursor
is properly inside the combobox.

However, suppose in the future, I desire the capability to select a
ComboBox programmatically and select all text inside (or put the cursor
inside, if no item has been chosen). How would one do that?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default ComboBox Problem

Private Sub Userform_Activate()
ComboBox1.SetFocus
If ComboBox1.Text = "" Then
ComboBox1.SelStart = 0
Else
ComboBox1.SelStart = 0
ComboBox1.SelLength = Len(ComboBox1.Text)
End If
End Sub


is a possibility. Worked for me with hiding the form.

--
Regards,
Tom Ogilvy

"R Avery" wrote in message
...
I figured out the problem, but it sure took a while. I tried your
suggestion, and it worked, for the first time only. Any subsequent
.Show's of the form did not have the cursor in the combobox. However,
when I tried to replicate my experience in a new simple form, I got the
same behavior.

I solved this for the simple form by doing an Unload Form1 before
showing the form each time, and it worked perfectly. However, that did
not work for my form.

It turns out that I had disabled the form QueryClose event by always
setting the Cancel parameter to TRUE. After removing that code, the
form was properly unloaded from memory, and when shown again, the cursor
is properly inside the combobox.

However, suppose in the future, I desire the capability to select a
ComboBox programmatically and select all text inside (or put the cursor
inside, if no item has been chosen). How would one do that?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default ComboBox Problem

I tried something similar to this before, and it did not work. However,
this code does work. I'm not sure why my code didn't work, but thanks
so much, Tom! This form now works great.


Tom Ogilvy wrote:

Private Sub Userform_Activate()
ComboBox1.SetFocus
If ComboBox1.Text = "" Then
ComboBox1.SelStart = 0
Else
ComboBox1.SelStart = 0
ComboBox1.SelLength = Len(ComboBox1.Text)
End If
End Sub


is a possibility. Worked for me with hiding the form.

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
ComboBox problem hoyos Excel Discussion (Misc queries) 4 December 10th 09 11:16 AM
Combobox Problem Tom Ogilvy Excel Programming 0 July 27th 04 06:38 PM
Combobox Problem Bob Phillips[_7_] Excel Programming 0 July 27th 04 06:28 PM
Combobox problem Ian Coates Excel Programming 4 February 21st 04 09:02 AM
ComboBox Problem Tressa Excel Programming 2 August 27th 03 08:58 PM


All times are GMT +1. The time now is 08:23 PM.

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"