?
Solved

ComboBox Issue

Posted on 2003-02-27
11
Medium Priority
?
151 Views
Last Modified: 2012-05-04
I want a ComboBox that is (*.)Locked but I still want entries to be selectable. In other words, I want entries in the pop-down list to be selectable, but I don't want the user to be able to enter anything manually. Is there a property that I'm missing, or is there any other way around this?
0
Comment
Question by:RuschWEB
  • 5
  • 5
11 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 8032627
Put the style of the Combobox to "2  - Dropdown list"

The user can choose a possibility, but can't enter data in combobox
0
 

Author Comment

by:RuschWEB
ID: 8032672
but then i can't put anything into myself even..
e.g.

MenuForm.TimeSlotChoice.Text = WordsLang(1)

..would not work. :\ because style 2 gives the combobox a read-only attribute.. :\ which i can't have.. is there a way i can change the style temporarily throughout the program?
i.e.
MenuForm.TimeSlotChoice.Style = 0
MenuForm.TimeSlotChoice.Text = WordsLang(1)
MenuForm.TimeSlotChoice.Style = 2

..or something like that?
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 8032684
You can add it with code

TimeSlotChoice.additem wordslang(1)

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:RuschWEB
ID: 8032735
But I don't want to add it to the list as an Item, i just want the Caption of it to become WordsLang(1) in this case.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 8032776
Know I can't follow any more....

You don't want the user to give the ability to enter data in the combobox. That's done by putting the liststyle to 2

You don't want to add something to the list. Is it the purpose to set the list automatically to the text you give (in this case wordslang(1), beacause that word is already in the list)... if that's what you mean then you have to do

TimeSlotChoice.listindex = 0
while timeslotchoice.listindex < timeslotchoice.listcount -1and timeslotchoice.list <> wordslang(1) then
   timeslotchoice.listindex = timeslotchoice.listindex +  1
wend

If that isn't the meaning, try to explain it better.
0
 

Accepted Solution

by:
sridhar12345 earned 150 total points
ID: 8032833
in the combobox_keypress event set the keyascii to 0
to restrict the user from entering his value
0
 

Author Comment

by:RuschWEB
ID: 8032934
Ok, sridhar12345 - thank you very much for your help. That solved my problem.

Private Sub TimeSlotChoice_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

May you live long and prosperous.. :P
0
 

Author Comment

by:RuschWEB
ID: 8033087
Well, before I loose my last points I just wanna ask..
I have an error handler that looks like this..

On Error GoTo ErrorHandler

ErrorHandler:
Select Case Err
Case 7 'out of memory
    tmp = MsgBox(WordsLang(80), vbCritical, WordsLang(85))
    Resume
Case 61 'harddisk full
    tmp = MsgBox(WordsLang(81), vbCritical, WordsLang(85))
    Close All
    End
Case 71 'disk not ready
    tmp = MsgBox(WordsLang(82), vbCritical, WordsLang(85))
    Resume
Case 72 'disk damaged
    tmp = MsgBox(WordsLang(83), vbCritical, WordsLang(85))
    Resume
Case 75 'path/file access error
    tmp = MsgBox(WordsLang(84), vbCritical, WordsLang(85))
    Close All
    End
Else
    tmp = MsgBox(WordsLang(87), vbCritical, WordsLang(85))
    Close All
    End
End Select

Where do I put the label, and where do I put the 'On Error' statement? In a sub somewhere?
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 8033129
on error: under your private/public sub declaration
errorhandler: just above end sub

Private Sub TimeSlotChoice_KeyPress(KeyAscii As Integer)
On Error GoTo ErrorHandler
   KeyAscii = 0
   exit sub
ErrorHandler:
Select Case Err
Case 7 'out of memory
   tmp = MsgBox(WordsLang(80), vbCritical, WordsLang(85))
   Resume
Case 61 'harddisk full
   tmp = MsgBox(WordsLang(81), vbCritical, WordsLang(85))
   Close All
   End
Case 71 'disk not ready
   tmp = MsgBox(WordsLang(82), vbCritical, WordsLang(85))
   Resume
Case 72 'disk damaged
   tmp = MsgBox(WordsLang(83), vbCritical, WordsLang(85))
   Resume
Case 75 'path/file access error
   tmp = MsgBox(WordsLang(84), vbCritical, WordsLang(85))
   Close All
   End
Else
   tmp = MsgBox(WordsLang(87), vbCritical, WordsLang(85))
   Close All
   End
End Select
End Sub
0
 

Author Comment

by:RuschWEB
ID: 8033198
but if i do that, wont it run the "case else" part when i change something in Private Sub TimeSlotChoice_KeyPress(KeyAscii As Integer)?
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 8033213
No, as long as there is no error, your error handler won't start
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…

609 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