Change lists of one listbox based on selection of other listbox?

N

NeedHelp

I asked this on anoter board:
If I have 2 list boxes, one that contains part numbers and one that contains
reasons why that part may be defective, how to do make it to where the list
given in the "reason" list box changes based on the part number selected in
the "part number" list box?

And I got this as an answer:

In the AfterUpdate event of the "part number" list box, modify the RowSource
property of the "reason" list box as appropriate:

lstReasons.RowSource = "SELECT [field] FROM [reasons] WHERE [part_number]='"
& lstParts & "'"

Of course, use your own table, field, and control names.



I am pretty good on computers but I can't seem to get this to work. I don't
know what the After Update event is for one. Also, can you be more specific,
the end with the '" & lstParts & "'" is confusing to me.

Thank you!
 
P

PJFry

The '" & lstParts & "" simply means that the list will set lstParts equal to
the value in the list box. So if you choose Headlight Fluid in the list box,
Access would see your RowSource as:
SELECT [field] FROM [reasons] WHERE [part_number] = 'Headlight Fluid'

If you look at your list box properities, you will see an Events tab.
AfterUpdate is there.

You will probably need to refresh the second list box as part of that after
update event.
 

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