PC Review


Reply
Thread Tools Rate Thread

Combobox default text

 
 
joeeng
Guest
Posts: n/a
 
      23rd Dec 2008
When the text property of a combobox is filled with for instance "Select an
Item", this is what displays when the form is opened. After a selection is
made from the drop-down, the selected item is displayed in the combobox. Is
there a way to clear the selection and reset the comobox display to the
default "Select an Item" after a selection has been made?
 
Reply With Quote
 
 
 
 
Jim Rech
Guest
Posts: n/a
 
      23rd Dec 2008
If you immediately negate the users' selection they will not be able to see
what they picked. It would be better to reset the combo after they do
something else, like click a "commit" button. You'd use code like
ComboBox1.ListIndex = 0 to do that.

--
Jim
"joeeng" <(E-Mail Removed)> wrote in message
news:97AA903C-600A-482D-B2C4-(E-Mail Removed)...
| When the text property of a combobox is filled with for instance "Select
an
| Item", this is what displays when the form is opened. After a selection
is
| made from the drop-down, the selected item is displayed in the combobox.
Is
| there a way to clear the selection and reset the comobox display to the
| default "Select an Item" after a selection has been made?

 
Reply With Quote
 
gsfeng
Guest
Posts: n/a
 
      24th Dec 2008


"joeeng" wrote:

> When the text property of a combobox is filled with for instance "Select an
> Item", this is what displays when the form is opened. After a selection is
> made from the drop-down, the selected item is displayed in the combobox. Is
> there a way to clear the selection and reset the comobox display to the
> default "Select an Item" after a selection has been made?

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      24th Dec 2008
You can add to the code you currently use in the Click or Change event that
does something with the user's selection as illustrated below. I used the
Change event but it will work in any of the event codes.

Private Sub ComboBox1_Change()
'Put code to execute on user selection here
chg = MsgBox("Click OK to reset ComboBox")
If chg = vbOK Then
ComboBox1.ListIndex = 0
End If
End Sub

The message box forces the user to click the OK button to reset the combo
box, since the only options on this type message box is OK or the big X close
icon. To be safe you could even include the X in the If statement:

If chg = vbOK Or chg = 1 Then
ComboBox1.ListIndex = 0
End If

The "1" is the value clicking the big X close.

"joeeng" wrote:

> When the text property of a combobox is filled with for instance "Select an
> Item", this is what displays when the form is opened. After a selection is
> made from the drop-down, the selected item is displayed in the combobox. Is
> there a way to clear the selection and reset the comobox display to the
> default "Select an Item" after a selection has been made?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How do you set the ComboBox default text Cor Microsoft VB .NET 4 8th Nov 2010 02:05 PM
Re: How do you set the ComboBox default text Cor Microsoft VB .NET 0 5th Nov 2010 08:10 AM
ComboBox.Items.Clear() causes the selection of Text inside the edit of the ComboBox Nomasnd Microsoft Dot NET Framework Forms 1 27th Sep 2006 06:32 PM
problem with combobox default display text yalanue@gmail.com Microsoft C# .NET 0 8th Aug 2006 01:34 AM
Default text in combobox Kyle Microsoft Access Forms 1 23rd Sep 2003 03:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:42 AM.