Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger Combo Box NotInList Event when List is changed by code

Status
Not open for further replies.

RottPaws

Programmer
Mar 1, 2002
478
US
I've got a form with 4 combo boxes, each with it's own list of valid items from the database and a default value of 'All'.

The combo boxes are cboProjName, cboProjType, cboProjCat, and cboProjPhase.

When an item is selected from the list of cboProjName, the list of cboProjType is refreshed using that value as a limiter. (i.e. only sub-Project Types that are valid for the selected Project Name are shown in the list).

A change to cboProjType similarly effects cboProjCat, and it in turn does the same to cboProjPhase.

The problem I'm having is when a sub-project type was already selected and a project name is selected that does not have that type of sub-project. The list gets refreshed, but then what is in the combo box is not on the list. When this happens, I'd like to trigger the NotInList event, but I can't figure out how to make this happen.

Any ideas? _________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
It's late and I'm sure I understand what exactly you are trying to do but here are a couple ideas to maybe get you started.

Assuming cboCB1 limits cboCB2 limits cboCB3 limits cboCB4, you could do something like the following:

cboCB1 after update event:
cboCB2.requery
cboCB3.requery
cboCB4.requery

cboCB2 after update event:
cboCB3.requery
cboCB4.requery

cboCB3 after update event:
cboCB4.requery

If you really need to add them on the fly try something like this:

cboCB2 after update event:
if dcount("Field", "Table", "Key = " & Key) = 0 then
cboCB1_NotInList or cbo3_NotInList or what ever
end if

The above assumes a numberic primary key. When using any aggregate function, you need a single quote for strings and a pound sign for date as below:

&quot;Key = '&quot; & StringKey & &quot;'&quot;) <== Note Single Quotes '
&quot;Key = #&quot; & DateKey & &quot;#&quot;) <== Note Pound Sign #

Good Luck!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top