Solved

combo box question

Posted on 2000-04-18
4
232 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
ID: 2728818
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
ID: 2728838
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
ID: 2728860
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
ID: 2728869
Thanks bhess1,  setting listIndex to -1 worked
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

776 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