Listbox value (1 Viewer)

kirkm

Registered User.
Local time
Tomorrow, 04:54
Joined
Oct 30, 2008
Messages
1,257
So, although a value is showing, you can never read what it is ? Please let me know so I can try something else. Thanks!
 

kirkm

Registered User.
Local time
Tomorrow, 04:54
Joined
Oct 30, 2008
Messages
1,257
? i there is no Highlight on the listbox, then nothing is selected therefore the its Value is Null (nothing).
Actually, no that is not true. In Form Load I have listPosTo = 10 after the 100 additems. This is so it initially shows 10.
? listPosto shows 10. even though nothing is selected.
 

moke123

AWF VIP
Local time
Today, 11:54
Joined
Jan 11, 2013
Messages
3,853
? i there is no Highlight on the listbox, then nothing is selected therefore the its Value is Null (nothing).
Actually, no that is not true. In Form Load I have listPosTo = 10 after the 100 additems. This is so it initially shows 10.
? listPosto shows 10. even though nothing is selected.
it should be highlighted as you are setting its value to 10 with code

with a value list you can set the listbox value to anything with code even if its not in the list.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:54
Joined
May 7, 2009
Messages
19,175
what is ListPosTo? what are you trying to solve List4 or ListpostTo.
actually Yes, when nothing is Highlighted, nothing is Selected, therefore No value.
if it is selected, even if you focus on another control, it will still be selected and will retain its Value.
 

kirkm

Registered User.
Local time
Tomorrow, 04:54
Joined
Oct 30, 2008
Messages
1,257
OK. Thanks for everyone's help. I've redesigned the Form to use a 3 line Dropdown and pre-slected default values to avoid Null.
I still think there should be a way to get the value showing in the Listbox (when there's no dropdown) without clicking it but I'll have to give up on that even though it worked better in the Form.
 

kirkm

Registered User.
Local time
Tomorrow, 04:54
Joined
Oct 30, 2008
Messages
1,257
Hi Arne as per Msg 1 ListPosto/From hold items 1 to 100. List4 contains 4 digit years from SQL. There's also a text box holding a start year (setup in another Form). The idea is the user selects a Year range, then a range anywhere between 1 and 100. I think the problem was no dropdown. Without that the user could click through to the required values, which nicely rotated into view. Excellent. Except bloody Access wouldn't let me get the value showing.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:54
Joined
Oct 29, 2018
Messages
21,360
Ah, on thinking more I have set a listbox height to 0.6cm to match some other controls. Is this preventing a drop down ?
Hi. Although you made the Listbox height only tall enough to show one item, that item is not selected until you click on it.
 

kirkm

Registered User.
Local time
Tomorrow, 04:54
Joined
Oct 30, 2008
Messages
1,257
I follow that, but it shouldn't be necessary as you've already just moved the item into view with the up/down things.
However it ain't a perfect world...
 

moke123

AWF VIP
Local time
Today, 11:54
Joined
Jan 11, 2013
Messages
3,853
I use a lot of listboxes and cant think many instances where I used one where I've had to scroll. If there are too many items to show in a list I would use a combobox. It would seem to me that you should be using a combobox for a 100 item list.

If you want to have a textbox with up/down arrows you can certainly do that with code.

edit:forgot to include that you can set a button to auto repeat in the property sheet.
 

Attachments

  • updown.accdb
    380 KB · Views: 118
Last edited:

AccessBlaster

Registered User.
Local time
Today, 08:54
Joined
May 22, 2010
Messages
5,830
If there are too many items to show in a list I would use a combobox.
You can have large data sets using listboxes, here is one holding 46,000 rows. I based it loosely on John Big Booty search listbox found here. You can wheel scroll or use the scroll bars or double click. It would be faster to use a search function with large data sets.

1602567882457.png
 

Attachments

  • 1602566859380.png
    1602566859380.png
    91.4 KB · Views: 101
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 08:54
Joined
Oct 29, 2018
Messages
21,360
I follow that, but it shouldn't be necessary as you've already just moved the item into view with the up/down things.
However it ain't a perfect world...
Hi. I think that's a misconception. If you enlarge your listbox to show two rows of items and click your down arrow a few times, which of the two items displayed is selected?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:54
Joined
Feb 19, 2002
Messages
42,989
Listboxes don't have dropdown arrows. They are fixed in height.

Also, why is your ListBox not bound to a RowSource query so you can avoid writing code to populate it?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:54
Joined
May 21, 2018
Messages
8,463
I reread this a few times, and it sounds what you describe is behavior like a spinner control. As you move up and down the value is selected. In the listbox you have to click into the list and select. See if this is the behavior you want. I put both the listbox shrunken down to show one row and a spinner control. The spinner control is an Active X control under MSFORMS
 

Attachments

  • Spinner.accdb
    1.6 MB · Views: 125

theDBguy

I’m here to help
Staff member
Local time
Today, 08:54
Joined
Oct 29, 2018
Messages
21,360
I reread this a few times, and it sounds what you describe is behavior like a spinner control. As you move up and down the value is selected. In the listbox you have to click into the list and select. See if this is the behavior you want. I put both the listbox shrunken down to show one row and a spinner control. The spinner control is an Active X control under MSFORMS
I agree with @MajP , I get the same impression about the OP wanting a spinner functionality. However, and this is directed at the OP, if you are populating the choices with values from 1 to 100, I wonder how effective a UI it would be to ask the user to click on a button 100 times to get the value 100?

Just a thought...
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:54
Joined
May 21, 2018
Messages
8,463
Although not suggesting this is a good UI, you actually do not have to click. You can just hold the button and set the delay to a very small number. It will scroll really fast automatically.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:54
Joined
Oct 29, 2018
Messages
21,360
Although not suggesting this is a good UI, you actually do not have to click. You can just hold the button and set the delay to a very small number. It will scroll really fast automatically.
Ah, that would be an advantage of using an ActiveX control over the original Listbox design then. Thanks!
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:54
Joined
May 21, 2018
Messages
8,463
However, still would think a combobox would be the best UI since it sounds like it is not multiselect.
 

kirkm

Registered User.
Local time
Tomorrow, 04:54
Joined
Oct 30, 2008
Messages
1,257
Hi. I think that's a misconception. If you enlarge your listbox to show two rows of items and click your down arrow a few times, which of the two items displayed is selected?
As far as I can tell, none. But you're only showing one item... then that's the one you want.
 

kirkm

Registered User.
Local time
Tomorrow, 04:54
Joined
Oct 30, 2008
Messages
1,257
Also, why is your ListBox not bound to a RowSource query so you can avoid writing code to populate it?
There isn't a rowsource query. That would mean having a table holdeing 1 to 100 ? Isn't additem in a loop far better ?
 

Users who are viewing this thread

Top Bottom