Scrolling a listbox to the end of list using vba (1 Viewer)

Kovenna

New member
Local time
Yesterday, 16:29
Joined
May 13, 2019
Messages
4
I have a form that I use to allow users to Add/Amend/Delete accounts (Chart of Accounts). I have inserted a listbox on the right of the input fields so that as an account is added/updated the user can see the effect on the whole table.

So far so good. However, as the user adds accounts, the list box fills up and as soon as the bottom most entry is added, the listbox spawns a right-hand scroll bar. All good stuff.

However, subsequent records that are added just disappear below the bottom of the listbox. It would be really useful to keep the latest added entries showing.

I have Googled this and apparently I should be using the "ListIndex" and "ListCount" properties of the Listbox. But in my version (Office 365 ie. Access 2016) thesed properties are non-existant. Am I missing a namespace/reference or something? Apparently these properties should be available from Access 2013. Really?

Can anyone help?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:29
Joined
Oct 29, 2018
Messages
21,453
Hi. Welcome to the forum! I'm not sure why those properties would be missing, but I don't have O365 to verify it. What code did you try? For example, if you do this, do you get an error?
Code:
MsgBox Me.ListboxName.ListCount
 

Kovenna

New member
Local time
Yesterday, 16:29
Joined
May 13, 2019
Messages
4
Hi TheDBGuy,


Thanks for your response;)


Most odd..now that I check it again, the properties are there as you say.


Oh dear, can't explain it. But thanks anyway!
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:29
Joined
Oct 29, 2018
Messages
21,453
Hi TheDBGuy,


Thanks for your response;)


Most odd..now that I check it again, the properties are there as you say.


Oh dear, can't explain it. But thanks anyway!
No worries. Glad you're sorted out. Good luck with your project.
 

Micron

AWF VIP
Local time
Yesterday, 19:29
Joined
Oct 20, 2018
Messages
3,478
You obviously can't see everything once you pass the row capacity of a listbox's size, so did you consider sorting as records are added? e.g. if pk is autonumber, sort by it descending. I'm not seeing how list index would really help. As you add/remove list items, the list index values change for every list item.*
EDIT: * if you insert/remove in between list items.
 

Users who are viewing this thread

Top Bottom