Solved

Prevent Edit of a Combo Box

Posted on 2002-06-03
6
701 Views
Last Modified: 2012-06-27
I have several combo boxes in an application I'm working on. I don't want to allow the users to just type something into the combo box - infact - I want them to be able to select ONLY a list item in the combo box.

I am still not sure if I want to allow them to type in the field (and catch the case where the typed value does not exist in the list) or to completely stop typing in the field. My personal preference (and from what I can tell the easier of the two options) would be the later.

I've played with validate, and lost focus. They don't quite behave how I want them to. For example, a user could type in string, click the continue button. This would call the lost_focus event which would determin that the string was bad, set the combo to some value (user would have no control of this) and then continue on...



Any ideas/code fragments greatly appriecated.

Woot.
0
Comment
Question by:woottond
  • 3
  • 2
6 Comments
 
LVL 22

Accepted Solution

by:
rspahitz earned 100 total points
ID: 7051720
If I understand you correctly, what you're looking for is in the Style property...set it to 2-Dropdown List.
0
 

Author Comment

by:woottond
ID: 7051826
perfect... now I have to figure out how to set the initial value - dum dee dum dum...

brb
woot.
0
 

Author Comment

by:woottond
ID: 7051838
done and done.

Thanks - save me hours of stupid work around coding.

=)

cheers,
woot.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 38

Expert Comment

by:PaulHews
ID: 7051840
>now I have to figure out how to set the initial value

Set the listindex property to correspond to the item you want.  (Points go to rspahitz)
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7051848
Combo1.Text = IntialValue

or

Combo1.ListIndex = Item_Between_0_And_ListCount-1


Glad to help.
0
 

Author Comment

by:woottond
ID: 7051867
yes -- got the listindex as soon as I looked at it, not sure why I hadn't thought to use the style property! had been playing with everything from lccked, enabled, to on_lost_focus, to validate...

cheers guys,
woot.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help in WHSCRIPT 9 47
Validating VB6 Function 19 56
VBA to copy paste columns form one file to other 20 85
How to incorporate an error traping routing to existing code in VB6 11 39
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

919 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now