Solved

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

Posted on 2011-03-24
6
278 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
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

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

Suggested Solutions

Title # Comments Views Activity
ms access 2010 vba, copy table from db1 to db2 from db3 27 46
Access on Mouse move 5 34
Create report using crosstab query 11 29
SQL Group on First occurrence 9 25
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
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…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

773 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