473,432 Members | 1,325 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Listbox value does not change

ken
Hi,
Say I have a list box. I also created a control on a form bound to that
list box. When I click different rows in the listbox the control
changes the ID of the row depending on what I click.

One thing I'm doing is setting the .selected(i) property of the list
box to true. On the screen I see that a different row gets hillighted,
but the bound control on the form is showing the wrong value?

So changing what is selected with code did not turn out to be the same
as cliking on the list box? Does this make any sense?

Dec 17 '05 #1
10 8523
Absolutely.
Perhaps you could explain "created a control on a form bound to that
list box."
as this might not mean the same thing to all of us
and/or
posting any code that you may be using to effect this binding would
help.

Dec 17 '05 #2
ken wrote:
Hi,
Say I have a list box. I also created a control on a form bound to that
list box. When I click different rows in the listbox the control
changes the ID of the row depending on what I click.

One thing I'm doing is setting the .selected(i) property of the list
box to true. On the screen I see that a different row gets hillighted,
but the bound control on the form is showing the wrong value?

So changing what is selected with code did not turn out to be the same
as cliking on the list box? Does this make any sense?

The mouse click should set your Selected property. One thing you might
want to consider is if you have ColumnHeading set to true. That offsets
you row count by 1.
Dec 17 '05 #3
ken
Hi,
Thanks for your reply.
Um..The control I'm refering to is a text box. Its Control Source is
=[LBox].Value

Here is how I change the selected property of the list box LBox:

For i = 0 To LBox.ListCount() - 1
If LBox.Column(0, i) = Me.pkItem Then
LBox.Selected(i) = True 'this changes the highlited value in the
list box
End If
Next
By the way this is a single select list box..can only select one thing.

Anyhow after that loop I see a change in the highlited row. So before I
had row 5(LBox.Value = 5) selected, after I had row 3 (LBox.Value = 3)
selected.

However my textbox tells me that I still have Row 5 (LBox.Value = 5)
selected?

Dec 17 '05 #4
ken
No that's not the issue...no offset. I'm talking about where a
different item gets selected, but the LBox.Value is still the old one...

Dec 17 '05 #5
On 17 Dec 2005 14:25:54 -0800, "ken" <ge****@gmail.com> wrote:
Hi,
Say I have a list box. I also created a control on a form bound to that
list box. When I click different rows in the listbox the control
changes the ID of the row depending on what I click.

One thing I'm doing is setting the .selected(i) property of the list
box to true. On the screen I see that a different row gets hillighted,
but the bound control on the form is showing the wrong value?

So changing what is selected with code did not turn out to be the same
as cliking on the list box? Does this make any sense?


Lyle is being particularly kind.

But, translating with a crystal ball, I guess that you have a bound
multi-select listbox. The list box can have multiple items selected.
The field that the listbox is bound to can only store one result.
Hence, a bound multi-select listbox is destined for confusion.

I'm not even sure why Access allows multi-select list boxes to be
bound. Endless confusion results.

You will need to walk the items of the listbox to determine whether
each is selected and then use the results accordingly, probably by
storing the value of each selected item somehow.

But I am just guessing.

mike

Dec 17 '05 #6
ken
Actually I have a single select list box...not multiselect!

Dec 17 '05 #7
Sometimes code like this doesn't run when it is in an event procedure.
We think the event has been fired because we have done something in
code. But it is not fired when do something in code.
To know if this might be a problem causing the behaviour you describe,
we need to know if this code lives in an event procedure, and if so,
which one.

Dec 18 '05 #8
ken
Its in the OnClick event for a command button. The function of the
command button is to 1. Change the selection in the List Box, and 2. To
refresh another Listbox in the form. Since the second list box depends
on the selected value of the first listbox, it would be nice for the
actual value of the first listbox to be updated when you change the
..selected property.

Thank you.

Dec 18 '05 #9
On 17 Dec 2005 14:57:17 -0800, "ken" <ge****@gmail.com> wrote:
Hi,
Thanks for your reply.
Um..The control I'm refering to is a text box. Its Control Source is
=[LBox].Value

Here is how I change the selected property of the list box LBox:

For i = 0 To LBox.ListCount() - 1
If LBox.Column(0, i) = Me.pkItem Then
LBox.Selected(i) = True 'this changes the highlited value in the
Insert here:

LBox.Value = LBox.Column(0, i)

mike
list box
End If
Next
By the way this is a single select list box..can only select one thing.

Anyhow after that loop I see a change in the highlited row. So before I
had row 5(LBox.Value = 5) selected, after I had row 3 (LBox.Value = 3)
selected.

However my textbox tells me that I still have Row 5 (LBox.Value = 5)
selected?

Dec 18 '05 #10
ken
That did it...thank you.

Dec 18 '05 #11

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

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
5
by: Bill | last post by:
I have have two list boxes. One is a listing of all possible variables. We'll call this listbox A. The other is a listing of all the selected variables. We'll call this listbox B. If a person...
7
by: Colleyville Alan | last post by:
I have an app in which users are displayed a list of mutual fund from which they can choose. There is a listbox embedded in a two-tabbed notebook control. When the form is initally opened, the...
2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
4
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
8
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the...
10
by: Adam Clauss | last post by:
I have a page containing a list box. This list may contain duplicate items - in which the ORDER is important. ex: a b b a is significant as compared to: b
21
by: Bilal Abbasi | last post by:
I realize that you can add items to a list box as objects so you can have access to more than just one property like the itemindex in vb6. Question I have is how do I cause the listbox to show a...
3
by: Kevin Walzer | last post by:
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: ...
5
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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
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...

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.