Results 1 to 4 of 4
  1. #1
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228

    Listbox "On Not In List" Property

    I am running a form in which the user needs to select an item that is included in the listbox. If the item is not in the listbox, I want a messagebox to come up and then it redirect you back to focusing on the listbox. I am unclear how to get this event to trigger. Every time I run the form and exit a listbox with something that is not part of the list, it does not trigger.

    I want it to be ok with being blank or with something from the list. How do I get this to trigger?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you talking about a ListBox or a ComboBox?

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I'm with RG on this, if you're using a list box, it's not physically possible to select something that's not in it. If you're talking about a combo box and if they type in something that's not available a default warning message appears, but you can change that if you want you just have to change the LIMIT TO LIST property.

    The easiest way to do this is to trap the error after setting the 'limit to list' property then in the ON EXIT property of the combo box use something like:

    Code:
    if err.number = <error number here> then
        <put your combo box name here> = null
        docmd.gotocontrol ("<put a control name that is always visible and enabled on your form here>")
        docmd.gotocontrol ("<put your combo box name here>")
    endif

  4. #4
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Thanks for the quick responses.

    In the meantime however I did find the "Limit to List" property somehow was set to No on a few of my listboxes. Not sure how this happened, but I was testing all of the listboxes and it would toss up an error on some and not on the others so I just searched for the difference between the two.

    For some reason I am having trouble with a very similar but different issue though. I'll start a new thread regarding it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 11-08-2013, 08:28 PM
  2. Filter Form with "CurrentRecord" property
    By bbrazeau in forum Forms
    Replies: 3
    Last Post: 05-24-2013, 10:16 AM
  3. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  4. Replies: 16
    Last Post: 11-01-2011, 01:35 PM
  5. Replies: 11
    Last Post: 11-26-2010, 10:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums