472,331 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 software developers and data experts.

Multi select listbox question...

I have a listbox set to simple multi select. For this example, users only
select one item at a time. I have command buttons on the form for First,
Previous, Next, Last, New (record). The form and listbox are unbound. The
listbox rowsource is a value list. The list box has about sixty items in
it. Each item in the list box corresponds to a record in the database.
When a user selects a row in the list box, the record is retrieved. The
same thing for if one of the command buttons is clicked. The problem is
that if I'm on the first record and I select the "Last" command button,
everything works fine except I can't see the highlighted last row of the
listbox. If I scroll down the listbox, the last row is correctly
highlighted, I just don't jump to it when "Last" is clicked.

My code is something like this: (Assume I'm on the first record then
clicking "Last"

MyListbox.Selected(1) = False
MyListbox.Selected(60) = True

How do I make the last row visible?

Thanks.

Matthew Wells
MW****@FirstByte.net

Nov 24 '06 #1
5 3981
Try setting the listboxes Value property to ItemData(x) where x is the
row you want to set.

On another note, you may want to set the MultiSelect prop for this
listbox to "None" if you are only using this listbox for record
navigation. There's no need to allow the user to select more than one
item in the listbox, and by extension, more than one record in the
recordset.

Also not clear on why you are using a "Value List" RowSourceType. If
you have a value in the list for every record in the table you're
drawing your records from, wouldn't it be more efficient to set the
RowSourceType to "Table/Query" and provide a RowSource?

Matthew Wells wrote:
I have a listbox set to simple multi select. For this example, users only
select one item at a time. I have command buttons on the form for First,
Previous, Next, Last, New (record). The form and listbox are unbound. The
listbox rowsource is a value list. The list box has about sixty items in
it. Each item in the list box corresponds to a record in the database.
When a user selects a row in the list box, the record is retrieved. The
same thing for if one of the command buttons is clicked. The problem is
that if I'm on the first record and I select the "Last" command button,
everything works fine except I can't see the highlighted last row of the
listbox. If I scroll down the listbox, the last row is correctly
highlighted, I just don't jump to it when "Last" is clicked.

My code is something like this: (Assume I'm on the first record then
clicking "Last"

MyListbox.Selected(1) = False
MyListbox.Selected(60) = True

How do I make the last row visible?

Thanks.

Matthew Wells
MW****@FirstByte.net
Nov 25 '06 #2
Doesn't work. The listbox has the correct value, it just doesn't move to
the highlighed record.

I have

LB.Value = sValue

The bound column is a string data type

Per your suggestion, I tried

With LB
.Value = .ItemData(.ListIndex)
End With

The resule is the same. No matter how the value is calculated on the right
hand side of "=", it's still assigning a string to the lb value property.

Per your comments:
If users only want to select one record at a time, they can. There are some
functions that users can do on multiple records - that's why it's
multi-select. If a user selects more that one record, most of the form
controls - (the navigation buttons and the fields in particular) become
disabled and only the command buttons that perform those functions mentioned
earlier remain enabled. The form is totally unbound, that's why the value
list. I could bind the lb to a disconnected recordset, but value lists
perform better.

I do thank you for your suggestion.
"Jamey Shuemaker" <ca*********@yahoo.comwrote in message
news:11**********************@h54g2000cwb.googlegr oups.com...
Try setting the listboxes Value property to ItemData(x) where x is the
row you want to set.

On another note, you may want to set the MultiSelect prop for this
listbox to "None" if you are only using this listbox for record
navigation. There's no need to allow the user to select more than one
item in the listbox, and by extension, more than one record in the
recordset.

Also not clear on why you are using a "Value List" RowSourceType. If
you have a value in the list for every record in the table you're
drawing your records from, wouldn't it be more efficient to set the
RowSourceType to "Table/Query" and provide a RowSource?

Matthew Wells wrote:
I have a listbox set to simple multi select. For this example, users
only
select one item at a time. I have command buttons on the form for
First,
Previous, Next, Last, New (record). The form and listbox are unbound.
The
listbox rowsource is a value list. The list box has about sixty items
in
it. Each item in the list box corresponds to a record in the database.
When a user selects a row in the list box, the record is retrieved. The
same thing for if one of the command buttons is clicked. The problem is
that if I'm on the first record and I select the "Last" command button,
everything works fine except I can't see the highlighted last row of the
listbox. If I scroll down the listbox, the last row is correctly
highlighted, I just don't jump to it when "Last" is clicked.

My code is something like this: (Assume I'm on the first record then
clicking "Last"

MyListbox.Selected(1) = False
MyListbox.Selected(60) = True

How do I make the last row visible?

Thanks.

Matthew Wells
MW****@FirstByte.net

Nov 25 '06 #3
Roger, the setup comments. Understood.

I'll have to play around with the selection stuff. I thought I had used
a similar process to select an item in a listbox on a form I use to
edit user groups, but it's possible that my list doesn't jump to the
desired position in the list either. I'll play around with that later,
and see if I can figure something out.

more later...

Nov 25 '06 #4
If the listbox is not a multiselect listbox you can set the selected
property of the last item in the list to true and the listbox will
scroll to that item. However, this doesn't work for multiselect
listboxes. You might try toggling off the multiselect property of the
listbox long enough to select the last record in the list and then
turning it back on again. You could also check out Stephen Lebans'
code here that may do what you need:

http://www.lebans.com/List_Combo.htm#ScrollListbox

HTH,
Bruce

Nov 27 '06 #5
That was interesting, but the .ListIndex property for Access listboxes is
read-only. I will try to toggle the multi-select.

Thanks.

Matthew Wells
MW****@FirstByte.et

<de***************@gmail.comwrote in message
news:11*********************@14g2000cws.googlegrou ps.com...
If the listbox is not a multiselect listbox you can set the selected
property of the last item in the list to true and the listbox will
scroll to that item. However, this doesn't work for multiselect
listboxes. You might try toggling off the multiselect property of the
listbox long enough to select the last record in the list and then
turning it back on again. You could also check out Stephen Lebans'
code here that may do what you need:

http://www.lebans.com/List_Combo.htm#ScrollListbox

HTH,
Bruce

Nov 28 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Lisa | last post by:
Hello, I am new to using recordsets, and i am completly stuck with this one. I am trying to use a multi select list box to write records to a...
3
by: google | last post by:
Hello, I am trying to create a listbox that users can select multiple entries on. I want Access to put each on of those selections in a different...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3...
2
by: George Durzi | last post by:
This is more of a design/philosophical question :) I have a page in which the user sets attributes for a project. There are 8 attributes, e.g....
4
by: Andy_Khosravi | last post by:
I'm trying to build a search utility for users to find 'inquiries' in my database that involves several tables. This is normally easy to do with...
4
by: gambit32 | last post by:
I have one multiselect box called 'listclient.' I have another multi-select box called 'listemployee.' I found some code that allows me to query...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code...
3
by: 6afraidbecause789 | last post by:
If able, can someone please help make a Where clause that strings together IDs in a multi-select listbox AND includes a date range. I wasn’t...
7
Curtis Rutland
by: Curtis Rutland | last post by:
Building A Silverlight (2.0) Multi-File Uploader All source code is C#. VB.NET source is coming soon. Note: This project requires Visual Studio...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.