Value pushed to textbox doesn't invoke LimittoList

M

moosecck

I have a form that uses a combo box called txt_Status with 3 options,
Draft, In Process and Approved. When the Status box is Approved, it
pushes the persons name from the thru code by using Environ
("Username") to a combo box called txt_Senior. Txt_Senior is a combo
box with 6 persons names in the list. It also has Limit to List
enabled. I have code in the Not in List of txt_Senior that tells
anyone whose name is not in the list to see their supervisor. My
problem is when the persons name is pushed into the txt_Senior box
where the Limit to List is enabled and the persons name is not in the
list, the NotInList code is not triggered. If I type the same name
into the txt_Senior box the NotInList code is triggered. Why is it
that when the name is pushed in the code does not work but when I type
the same name into the txt_Senior box the NotInList code is triggered?
 
M

mat

I have a form that uses a combo box called txt_Status with 3 options,
Draft, In Process and Approved. When the Status box is Approved, it
pushes the persons name from the thru code by using Environ
("Username") to a combo box called txt_Senior. Txt_Senior is a combo
box with 6 persons names in the list. It also has Limit to List
enabled. I have code in the Not in List of txt_Senior that tells
anyone whose name is not in the list to see their supervisor. My
problem is when the persons name is pushed into the txt_Senior box
where the Limit to List is enabled and the persons name is not in the
list, the NotInList code is not triggered. If I type the same name
into the txt_Senior box the NotInList code is triggered. Why is it
that when the name is pushed in the code does not work but when I type
the same name into the txt_Senior box the NotInList code is triggered?
I'm not sure why this is true but by design many form events are only
triggered by user interactions. Seemingly parallel actions carried out
in code don't trigger the events.

I've not needed to deal with the specific issue you've asked about, but
you should be able to work around it by testing the list in code for a
match, and if a match is not found, fire the not in list event.
 
D

Dirk Goldgar

I have a form that uses a combo box called txt_Status with 3 options,
Draft, In Process and Approved. When the Status box is Approved, it
pushes the persons name from the thru code by using Environ
("Username") to a combo box called txt_Senior. Txt_Senior is a combo
box with 6 persons names in the list. It also has Limit to List
enabled. I have code in the Not in List of txt_Senior that tells
anyone whose name is not in the list to see their supervisor. My
problem is when the persons name is pushed into the txt_Senior box
where the Limit to List is enabled and the persons name is not in the
list, the NotInList code is not triggered. If I type the same name
into the txt_Senior box the NotInList code is triggered. Why is it
that when the name is pushed in the code does not work but when I type
the same name into the txt_Senior box the NotInList code is triggered?


The NotInList event is triggered by user action, not by assigning a value in
code. Access tends to assume that if the developer is assigning a value
(via code), it must be valid. If you need to, you can make your own test to
see if the name is valid, either by checking it against the combo box's list
or by checking it against the combo's rowsouce. Or you can assign the value
to the combo and then check the combo's ListIndex property to see if the
value you assigned is valid (the ListIndex will be -1 if the value is not in
the list).
 
M

Marshall Barton

mat said:
I'm not sure why this is true but by design many form events are only
triggered by user interactions. Seemingly parallel actions carried out
in code don't trigger the events.

I've not needed to deal with the specific issue you've asked about, but
you should be able to work around it by testing the list in code for a
match, and if a match is not found, fire the not in list event.


It is not necessary to search the list for a match. The
ListIndex property will be -1 if the the value is not in the
list.
 

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

Similar Threads

LimitToList Error 2
Drop Down Search Box 2
Automatically Add Entry to Combobox 13
Need help with this NotInList code for a combo box 4
LimitToList Event 5
NotInList help 3
Not In List question 1
Combo Box Look UP 3

Top