?
Solved

ComboBox Issue

Posted on 2003-02-27
11
Medium Priority
?
147 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
[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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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

762 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