Force user to enter an item from a list box

G

Guest

Hi,

I have a bounded form that has a dropdown list called "Type", this dropdown
list can be left blank(is not a required field to submit the form) , but my
cocern is that is if the list needs to be used, then the user should only be
able to select from the list and not type a third option like my users have
been doing
How do I enforce this?

I appreciate your sugestions
 
G

Guest

You are using a list box, you can't type anything into it. You are saying
list box, but I think you really are using a Combo Box. If that is the case,
you use the Not In List event to tell the user to use only what is in the
list. You also have to set the limit to list property to Yes.
 
G

Guest

"Klatuu"

you are right I meant a combo box. Could you please provide more details on
how to use the not on list event?

Thanks
 
S

Steve Schapel

Pardon me for butting in... If you look at the Properties of the
combobox, in design view of the form, you will see a property Limit To
List. Set this property to Yes... that's all you will need to do.
 
G

Guest

Private Sub cboActivity_NotInList(NewData As String, Response As Integer)

MsgBox NewData & " Is Not In the List" & vbNewLine & "Please Select From
the List", vbExclamation
Response = acDataErrContinue

End Sub

Just be sure to set the Limit to List property to Yes or the Not In List
event will not fire.
 
G

Guest

Thanks to the to of you.

Klatuu said:
Private Sub cboActivity_NotInList(NewData As String, Response As Integer)

MsgBox NewData & " Is Not In the List" & vbNewLine & "Please Select From
the List", vbExclamation
Response = acDataErrContinue

End Sub

Just be sure to set the Limit to List property to Yes or the Not In List
event will not fire.
 
G

Guest

No problem, Steve, always interested in other ideas and opinions.

You are technically correct; however, I prefer to offer my users better
messages than those presented by Access.
 
S

Steve Schapel

Hi Dave,

First of all, I'm sorry I didn't mean to give the impression that I was
contradicting you. And also my eyes were playing tricks on me
apparently, in that somehow I thought there had been a significant delay
since your earlier reply. Sorry.

However, now that you bring this up, I must say I agree with you in
general. But in the case of the Limit To List violation, in my opinion
the native message:
"The text you entered isn't an item in the list"
.... isn't too bad. :)
 
G

Guest

Hi Steve,

I didn't think your information was contradictory at all.

In this case, I would agree the message is not too bad, but you know that
sometimes the messages can be confusing.

But still as a matter of habit and because I like to present a consistent
style including the messages and the title, I always roll my own.

And, I was not challenging your answer, just offering a different approach.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top