Solved

combo box question

Posted on 2000-04-18
4
211 Views
Last Modified: 2010-05-02
I have a combobox (cboValue) that has three values, A, B, and C.  A user can ONLY enter one of these 3 values, so I made the type of combobox a dropdown list.  However I have a clear button (btnClear) that clears the combobox.

Private Sub btnClear_Click()
cboValue.text=""
End sub

But when I click on the btnClear I get an error "Text property is read only".  If I turn the combobox to a dropdown combo it will work, but I do not want users to enter in a value that is not on the list.

Is there a work around?

Thanks
0
Comment
Question by:sopheak
4 Comments
 
LVL 6

Expert Comment

by:Marine
Comment Utility
what you can do is you can comare if the value entered is found in the list. You can quickly loop though the list and see if values match. If not then give a message.
0
 
LVL 32

Accepted Solution

by:
bhess1 earned 50 total points
Comment Utility
If the selection in the combobox is not mandatory, add a fourth, blank selection to the box.  On the clear button click, select the first item.

Alternately, set the ListIndex to -1 (not selected) on the clear button click.
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Private Sub btnClear_Click()
  cboValue.Clear
End Sub

Private Sub Form_Load()
  cboValue.AddItem "A"
  cboValue.AddItem "B"
  cboValue.AddItem "C"
  cboValue.ListIndex = 0
End Sub

Cheers
0
 

Author Comment

by:sopheak
Comment Utility
Thanks bhess1,  setting listIndex to -1 worked
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now