Solved

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

Posted on 2011-03-24
6
279 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

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…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

820 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