Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / December 2007

Tip: Looking for answers? Try searching our database.

Combo Box - Limit to List

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin - 13 Dec 2007 17:34 GMT
Hello,

I have a combo box that has a list derived from a query.  I want the user to
only select data in the combo box and I have set the limit to list property
to yes but users can still type in anything they want.  The error message
does display stating that it doesn't match the value in the list but I want
to prevent the user from typing in anything at all other than those in the
list.

Can anyone help?

I don't want to use a list box.

Martin
akphidelt - 13 Dec 2007 17:39 GMT
Can I ask why?

Cause regardless if you limit to the list they can't leave that combobox
until there is something that is in the list.

> Hello,
>
[quoted text clipped - 10 lines]
>
> Martin
Mark A. Sam - 13 Dec 2007 19:01 GMT
I find that prohibiting typing in comboboxes makes a cleaner application
where there are only a few choices to be made.  When the user clicks on the
combo, the list drops and he makes the choice.

> Can I ask why?
>
[quoted text clipped - 19 lines]
>>
>> Martin
Ron2006 - 13 Dec 2007 21:04 GMT
> I find that prohibiting typing in comboboxes makes a cleaner application
> where there are only a few choices to be made.  When the user clicks on the
[quoted text clipped - 25 lines]
>
> - Show quoted text -

However, stopping the ability to type also stops the auto complete
functionality.

Ron
Mark A. Sam - 13 Dec 2007 21:49 GMT
Correct, but for my purpose it doesn't matter, becuase the mouse is used to
select.

>> I find that prohibiting typing in comboboxes makes a cleaner application
>> where there are only a few choices to be made.  When the user clicks on
[quoted text clipped - 34 lines]
>
> Ron
Bob Quintal - 13 Dec 2007 22:34 GMT
> Correct, but for my purpose it doesn't matter, becuase the mouse
> is used to select.

You are the only user of the database?
Or are you one of those arrogant coders who insist that their way is
correct and everybody who has a different way is an id10t?

Use the combobox's On Key Press event to capture all keystrokes and
discard them, possibly  except for the enter key and or escape key.

Q

> "Ron2006" <ronnemec@hotmail.com> wrote in message
> news:ab3686f3-1a4d-42f6-a30b-f516c678276c@d4g2000prg.googlegroups.c
[quoted text clipped - 42 lines]
>>
>> Ron

Signature

Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Mark A. Sam - 14 Dec 2007 19:46 GMT
Bob,

You misunderstood me.  I was just answering Ron.  I don't think there are
many times to use this method, but if there are only a few, static choices,
it can work well. If circumstances changed and the list increased then the
method could easily be changed.  Any methodolgy would depend on the user and
the usage.

God Bless,

Mark

>> Correct, but for my purpose it doesn't matter, becuase the mouse
>> is used to select.
[quoted text clipped - 55 lines]
>>>
>>> Ron
Bob Quintal - 15 Dec 2007 00:13 GMT
> Bob,
>
[quoted text clipped - 7 lines]
>
> Mark

My apologies. Ron's the one that needs to answer the questions (to
himself if not to me) before he alienates a lot of users.


>>> Correct, but for my purpose it doesn't matter, becuase the mouse
>>> is used to select.
[quoted text clipped - 58 lines]
>>>>
>>>> Ron

Signature

Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Ron2006 - 17 Dec 2007 13:11 GMT
> > Bob,
>
[quoted text clipped - 91 lines]
>
> - Show quoted text -

Ron?

I just said it disables the autocomplete.

Ron
Bob Quintal - 17 Dec 2007 22:02 GMT
Ron2006 <ronnemec@hotmail.com> wrote in
news:d3771333-63f6-4d7c-9482-
36bcc686f15e@d21g2000prf.googlegroups.co
m:

>> > Bob,
>>
[quoted text clipped - 10 lines]
>> My apologies. Ron's the one that needs to answer the questions
>> (to himself if not to me) before he alienates a lot of users.

> Ron?
>
> I just said it disables the autocomplete.
>
> Ron

Sorry Ron, I mistook you for the Original Poster. The OP is the one
that needs to abnswer the question. Quoting seems to have mangled
who said what.

Signature

Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Klatuu - 13 Dec 2007 17:46 GMT
Use the NotInList event for your combo:

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

   MsgBox "You Must Select From the List"
   Response = acDataErrContinue
   Me.MyCombo.Undo

End Sub

Signature

Dave Hargis, Microsoft Access MVP

> Hello,
>
[quoted text clipped - 10 lines]
>
> Martin
Mark A. Sam - 13 Dec 2007 18:55 GMT
In the KeyDown event type this:

KeyCode = 0

That will prevent typing anything at all into the combobox.

God Bless,

Mark A. Sam

> Hello,
>
[quoted text clipped - 13 lines]
>
> Martin
Martin - 13 Dec 2007 21:33 GMT
Thank you all for your responses, most helpful.  In particular, thank you
Mark A. Sam, just what was needed.  

Martin

> In the KeyDown event type this:
>
[quoted text clipped - 23 lines]
> >
> > Martin
Dirk Goldgar - 13 Dec 2007 21:36 GMT
> In the KeyDown event type this:
>
> KeyCode = 0
>
> That will prevent typing anything at all into the combobox.

It will also prevent the user from tabbing out of the combo box.  It would
probably be better to exclude the Tab and Enter keys from that blanket
prohibiton on typing.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Martin - 13 Dec 2007 21:49 GMT
Dirk,

Sorry, I am not that advanced.  Can you expand on that.  I have just tested
the Keycode method and it does what I need expect as you say does not allow
the tab button to work.

Martin

> > In the KeyDown event type this:
> >
[quoted text clipped - 5 lines]
> probably be better to exclude the Tab and Enter keys from that blanket
> prohibiton on typing.
Mark A. Sam - 13 Dec 2007 21:52 GMT
Dick,

That's true, but can be accounted for.

If KeyCode <> 9 Then 'Tab key pressed
 KeyCode = 0
End If

God Bless,

Mark

>> In the KeyDown event type this:
>>
[quoted text clipped - 5 lines]
> probably be better to exclude the Tab and Enter keys from that blanket
> prohibiton on typing.
Martin - 13 Dec 2007 22:06 GMT
Genius!

> Dick,
>
[quoted text clipped - 17 lines]
> > probably be better to exclude the Tab and Enter keys from that blanket
> > prohibiton on typing.
Dirk Goldgar - 13 Dec 2007 22:15 GMT
> Dick,

Dirk

> That's true, but can be accounted for.
>
> If KeyCode <> 9 Then 'Tab key pressed
>  KeyCode = 0
> End If

Exactly.  Though you probably want to allow 13 as well:

   Select Case KeyCode
       Case 9, 13
           ' Allow these
       Case Else
           ' Ignore all other keys.
           KeyCode = 0
   End Select

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.