Solved

combo box question

Posted on 2000-04-18
4
240 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 28

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

837 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