Solved

How to take a combo box on Access Form so user can't type in the box?

Posted on 2011-03-24
6
276 Views
Last Modified: 2012-05-11
Hello,

I have a form with a combo box on it and a user can type things or even remove the selections and save values that are not listed in the combo. How can I have the combo box act more like a drop down list box, so the user can't type in values that are not in the list?
0
Comment
Question by:gtrapp
6 Comments
 
LVL 8

Expert Comment

by:pdd1lan
ID: 35211794
try DropDownStyle property to DropDownList
0
 
LVL 75
ID: 35211796
Set the Limit To List property to Yes.

mx
Capture1.gif
0
 

Author Comment

by:gtrapp
ID: 35211837
I have Limit To List property to Yes, but I am able to clear out the selected value and save a blank to the record. Only want users to select a value in the list and save that value.

Where is the DropDownList property set?

I am using Access 2007 and have 3 values to select from in the combo box.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 35211873
Limit To List should do this.  Something else is going on then.  However, Limit To List does not prevent a  user from backing out an existing entry, then saving a 'blank' (Null) value.  To prevent that, you need to make that field required in your table or do validation at the Form level ... that the value is present and Not Null.

mx
0
 
LVL 26

Expert Comment

by:Nick67
ID: 35211953
As @DatabaseMX said, Limit to List should prevent silliness.  In your image, you don't show where the box is getting its data from.
That may be why Limit to List isn't working.  It is hard to limit it to a non-existent list.

Limit to List makes the NotInList event fire when an attempt to add something new occurs.
Validating can get done in there too
Private Sub Combo0_NotInList(NewData As String, response As Integer)
    Select case true
        case NewData = "Some value I like 1"
            response = acDataErrAdded
        case NewData = "Some value I like 2"
            response = acDataErrAdded
        case NewData = "Some value I like 3"
            response = acDataErrAdded
        case Else
            Msgbox "That response was NFG, try again!"
            response = acDataErrContinue
    End Select 
End Sub

Open in new window

0
 
LVL 75
ID: 35212110
Nick >> "and have 3 values to select from in the combo box."

"Validating can get done in there too"
The Not In List is not for validating data per se.  It's to allow the user to capture the fact, and present a user friendly message and/or add the item to the List.

mx
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

705 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