Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

combo box question

Posted on 2000-04-18
4
Medium Priority
?
263 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:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Suggested Courses

916 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