Setting Listindex property

I

IAIN Mac

I want my listbox to highlight a given row based either on
the value I want it to have or else on the first row after
a requery to change the list.

I tried assigning it a value, but that didnt work, and I
tried setting listindex value by following the help
instructions:
Forms(formname).Controls(controlname).ListIndex = index

I immediately got an eror telling me I was not using the
listindex property correctly.

I even tried substituting the integer value for the
controlname, checking I had it right by watching the
controlname property....#

Any suggestions as to what i can do?
Its a really basic expectation and access (again!) makes
it hard!
Sigh!

Help?
 
V

Van T. Dinh

Is it a Single-Select ListBox or Multi-Select ListBox?

If it is Single-Select and not bound to a Field in the Form's RecordSource,
you should be able to set the value of the ListBox. Make sure you set its
value to the value in the *bound* Column of the required row in the
RowSource for the ListBox.

IIRC and if you still want to use the ListIndex, I think you need to set the
focus to the ListBox before you can assign the "index" value to the
ListIndex.
 
I

IAIN Mac

I tried seting focus and still got runtime error 7777 -
incorrect use of listindex prop.
 
D

Dirk Goldgar

IAIN Mac said:
I want my listbox to highlight a given row based either on
the value I want it to have or else on the first row after
a requery to change the list.

I tried assigning it a value, but that didnt work, and I
tried setting listindex value by following the help
instructions:
Forms(formname).Controls(controlname).ListIndex = index

I immediately got an eror telling me I was not using the
listindex property correctly.

I even tried substituting the integer value for the
controlname, checking I had it right by watching the
controlname property....#

Any suggestions as to what i can do?
Its a really basic expectation and access (again!) makes
it hard!
Sigh!

Help?

Please post your code, and tell us whether your list box is multiselect
or not.
 

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