Programatically selecting an item in a listbox

B

Brad Borgeding

I'm getting an error about incorrect use of the listindex property in this
situation.

I have two listboxes on a form. The second one is dependent on the first so
when an item is selected in the first, I do a requery on the second and then
try to select the first item in the second listbox. The code is like this:

listbox2.requery
listbox2.listindex = 0

The error occurs on the statement setting listindex to 0. After the
requery, the second listbox always will have at least one value.

What's the correct way to programatically select an item in a listbox?

Thanks,
Brad
 

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