Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

combo box question

Posted on 2000-04-18
4
Medium Priority
?
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:
Brendt Hess earned 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 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…
Suggested Courses

715 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