List box questions - driving me crazy

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have a table that contains document metadata for a set of reference
documents.
I have a form that displays the metadata in separate fields. On the form I
also
have a list box that only lists the document titles. When the user clicks
on a title,
the detailed document metadata gets displayed on the form. That all works
wonderfully.

My problems:
1. When the form first opens, the document details that are displayed are
NOT from the first document (sorted by title, even though I have set it to
be).
2. The list box is nicely ordered by title, as desired, but there is not
selected item.

Can someone help me with these? If I use the listbox.selected property, I
can
select any item I want in the list box, but then clicking seems to be
disabled
(at least the AfterUpdate method isn't being called).

Sorry if the answers have been posted previously. I have looked and
looked....
Thanks
 
You can set a selected item for the List Box in the Load event of the form.
This example selects the first row in the list:

Me.lstMyList.Selected(0) = True
 
I did try that, and yes, it selected the first item in the list. However, it
seems
to have disabled clicking in the list box. I can click to my hearts content
and
nothing gets selected.
 
That is not the cause of your problem. You can programmatically select and
un select items without affecting what the user does.
Check your list box properties. This may be an issue with the Multi Select
property.
 
My list box isn't Multi-Select, but I fixed (sort of) the problem by moving the
..Selected(0) = True to the Form_Load function instead of putting it in the
Form_Open function. Why did that make a difference?

So now I can select to my hearts desire, but the value of the list box never
gets
updated. After_Update doesn't automatically get called, and even if I call
it
myself the value in the list box is the old "last time clicked with mouse"
value.
Why is this? What am I missing?

Thanks for you help.
 
It should not make a difference in behaviour; however, the Open event is too
soon to reference any control as the reference may or may not have been
established.

Try using the Click event instead of the After Update.
 
I found that this works for me (it came from a 2003 posting in Google groups,
so
it's a little old, but it worked)

Me.lst_ListOfDocuments.Selected(index) = True
Me.lst_ListOfDocuments = Me.lst_ListOfDocuments.Column(0, (ndex)
Call lst_ListOfDocuments_AfterUpdate

Thanks for your help, though. Dana
 
Back
Top