why does default=itemdata(0) not work?

F

Frederick Wilson

Hello,

I have a form that has a combo box and a list box. The list box is based
off of the selection for the combo box

cboBox Rowsourse=
SELECT distinct TngType FROM tblEvents UNION select "[ALL]" from
tblevents ORDER BY tblEvents.TngType;

the listbox Rowsourse=
SELECT tblEvents.EventCode, tblEvents.Event, tblEvents.TngType FROM
tblEvents WHERE (((tblEvents.TngType) Like
IIf(Forms!frmInputCTT!cboEventType="[ALL]","*",Forms!frmInputCTT!cboEventType)))
ORDER BY tblEvents.Event;

The overall function works fine BUT...
When I set the default value of the cbo to =
[cboEventType].[itemdata](0) the query for the list box fails when the
form opens.

If I remove the reference to the cbo from the list box row source, the
list box shows everything and the cbo shows the first item. However now
the afterupdate event in the cbo fails to requery the list box.

How do I get this to work?
 
P

Paul Overway

If you have row headings shown in the combo box, the heading is
[itemdata](0).

Another way to do this....

cboBox Rowsourse=
SELECT distinct TngType FROM tblEvents ORDER BY tblEvents.TngType;

the listbox Rowsourse=
SELECT tblEvents.EventCode, tblEvents.Event, tblEvents.TngType FROM
tblEvents WHERE tblEvents.TngType Like
Nz(Forms!frmInputCTT!cboEventType),"*")
ORDER BY tblEvents.Event;

If nothing is entered in the combo, everything will be shown in the list
box. You're using the combo as a filter, so, this is still fairly intuitive
for the user. Saves you from doing the union query which also makes it
nominally faster.

You'll also need a listbox.requery in the AfterUpdate event of the combo.
 

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