473,513 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4071
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
6331
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 table. Something in my code is causing the same...
3
4627
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 row on a particular table. This table will also...
18
3321
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 columns. I would like to display 2 of those...
2
5832
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. Project Type, Country, etc. The number of options...
4
3166
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 the query builder, but I have a unique situation...
4
1601
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 on the listclient box. I'm trying to figure out...
17
3108
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 that I cannot seem to correct. I will also note...
3
3246
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 thinking when I used the code below that strings...
7
7125
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 2008 SP1 or Visual Web Developer 2008 SP1 and...
0
7259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.