Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SELECTING LISTBOX ITEM

0 views
Skip to first unread message

Paul Martin

unread,
Mar 2, 2003, 9:07:25 AM3/2/03
to
Hi All,
I have a quotations form opened via a list of available
quotes, but am finding that as I requery the listbox when
closing the quotations form, the selected item is changed
to the first in the list. This is driving me nuts!
Is there any way to use the QuoteID that I pass back to
the list to make that the selected item?
Thanks for any help.
Paul

MacDermott

unread,
Mar 2, 2003, 1:07:10 PM3/2/03
to
If it is a single select listbox, you can simply set the value of the
listbox to the QuoteID.

HTH
- Turtle

"Paul Martin" <pma...@serendipitysys.com> wrote in message
news:032a01c2e0c5$0cf8b440$a301...@phx.gbl...

Paul Martin

unread,
Mar 2, 2003, 1:58:31 PM3/2/03
to
I might be being really dense here, but how? It is just a single select
listbox that I'm using.

Thanks & Regards,
Paul

"MacDermott" <macde...@mindspring.com> wrote in message
news:O1Up0aO4...@TK2MSFTNGP09.phx.gbl...

MacDermott

unread,
Mar 2, 2003, 2:59:47 PM3/2/03
to
If your listbox is named MyListbox, the code would look like this:
MyListbox=QuoteID

Replace MyListbox with the name of your listbox.

HTH
= Turtle

"Paul Martin" <pma...@serendipitysys.com> wrote in message

news:yvs8a.3289$gq3....@newsfep1-gui.server.ntli.net...

Paul Martin

unread,
Mar 3, 2003, 6:42:02 AM3/3/03
to
Thanks for this. However, I know that if I do a debug.print it gives me the
correct result, but there is no selected item on the listbox. I tried
returning the ListIndex, but this gives me -1 and without an index, I don't
see how I can use .Selected.

The listbox itself is part of an unbound form. The bound column of the list
is governed by an option box which is used to allow searches (so it may be
Column 1 for the customer name, column 2 for quote reference, etc.). Because
of this, I have to change the BoundColumn property to 0 in order to use your
code snippet (no errors thrown out here), but I don't seem to get anywhere.

My code is
With forms!frmCustQuoteList
.Visible = true
!lstIncSrch.BoundColumn = 0
!lstIncSrch.Requery
!lstIncSrch = QuoteID
End With

I hope this makes sense to you and that you can offer me some idea as to
what I've done wrong.

Thanks & Regards,
Paul

"MacDermott" <macde...@mindspring.com> wrote in message

news:OfhOwZP4...@TK2MSFTNGP10.phx.gbl...

MacDermott

unread,
Mar 3, 2003, 12:55:47 PM3/3/03
to
Thanks for your detailed description.
Is this a multi-select listbox?

What is the expression that you are debug.print - ing?

- Turtle

"Paul Martin" <pma...@serendipitysys.com> wrote in message

news:ncH8a.581$DH5...@newsfep1-gui.server.ntli.net...

Paul Martin

unread,
Mar 3, 2003, 2:04:04 PM3/3/03
to
No, it's not a multi-select listbox. It actually works as a large combo-box,
so as you start typing a company name or quote reference, it moves the
selected item down the list until you hit the one you want.
The debug.print was to prove to myself that the listbox = QuoteID after
setting it as such (although strangely, if I debug.print .Column(0), a null
is returned).
The problem remains though, I don't actually get a selected item on the
list. I have made a little progress in that if I take the ListIndex value
before running the requery, I can then return to the same point on the list
after the requery (using .Selected(ListIndex)). Unfortunately, this isn't
any good if the position within the list has changed, or else it is a new
quotation.
Thanks for your help,
Regards,
Paul

"MacDermott" <macde...@mindspring.com> wrote in message

news:u7VTH5a4...@TK2MSFTNGP12.phx.gbl...

MacDermott

unread,
Mar 3, 2003, 9:26:21 PM3/3/03
to
Sorry I didn't catch this sooner:
This is one of those exasperating little quirks of Access:
BoundColumn is 1-based; the first column is 1, not 0
so cbo.BoundColumn=0 won't bind any existing row.

Try it with BoundColumn=1!

HTH
- Turtle

"Paul Martin" <pma...@serendipitysys.com> wrote in message

news:NGN8a.1215$DH5....@newsfep1-gui.server.ntli.net...

Paul Martin

unread,
Mar 4, 2003, 8:42:35 AM3/4/03
to
That's sorted it! Can't believe I didn't see this either.
Thanks ever so much for your help, it's really appreciated.
Regards,
Paul

"MacDermott" <macde...@mindspring.com> wrote in message

news:OglOaWf4...@TK2MSFTNGP10.phx.gbl...

0 new messages