Solved

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

Posted on 2011-03-24
6
277 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

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
Close Print Preview button not active 12 35
Cross Tab with two column values 7 32
Export Query data to excel file 14 26
Access 2010 Query Syntax 5 15
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

932 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

14 Experts available now in Live!

Get 1:1 Help Now