Moving to position of multi select listbox
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a multi select listbox, which I would like to make searchable. If the searched for value is found in the listbox, I'd like to scroll to that position, but not select it. Is this possible? The code I have so far for searching is :-
With lstComm
For i = 0 To .ListCount - 1
If .Column(6, i) = txtSearch.Value Then
End If
Next i
End With
...but I'm not sure how to complete the scroll.
vba ms-access access-vba
add a comment |
I have a multi select listbox, which I would like to make searchable. If the searched for value is found in the listbox, I'd like to scroll to that position, but not select it. Is this possible? The code I have so far for searching is :-
With lstComm
For i = 0 To .ListCount - 1
If .Column(6, i) = txtSearch.Value Then
End If
Next i
End With
...but I'm not sure how to complete the scroll.
vba ms-access access-vba
1
Access doesn't offer a built-in way to scroll list boxes. I can write up a WinAPI answer if you're interested, but it will be rather complicated since Access doesn't offer a built-in way to get the hWnd for a form control.
– Erik A
Nov 14 '18 at 11:34
add a comment |
I have a multi select listbox, which I would like to make searchable. If the searched for value is found in the listbox, I'd like to scroll to that position, but not select it. Is this possible? The code I have so far for searching is :-
With lstComm
For i = 0 To .ListCount - 1
If .Column(6, i) = txtSearch.Value Then
End If
Next i
End With
...but I'm not sure how to complete the scroll.
vba ms-access access-vba
I have a multi select listbox, which I would like to make searchable. If the searched for value is found in the listbox, I'd like to scroll to that position, but not select it. Is this possible? The code I have so far for searching is :-
With lstComm
For i = 0 To .ListCount - 1
If .Column(6, i) = txtSearch.Value Then
End If
Next i
End With
...but I'm not sure how to complete the scroll.
vba ms-access access-vba
vba ms-access access-vba
edited Nov 14 '18 at 11:23
user1936588
asked Nov 14 '18 at 11:12
user1936588user1936588
511515
511515
1
Access doesn't offer a built-in way to scroll list boxes. I can write up a WinAPI answer if you're interested, but it will be rather complicated since Access doesn't offer a built-in way to get the hWnd for a form control.
– Erik A
Nov 14 '18 at 11:34
add a comment |
1
Access doesn't offer a built-in way to scroll list boxes. I can write up a WinAPI answer if you're interested, but it will be rather complicated since Access doesn't offer a built-in way to get the hWnd for a form control.
– Erik A
Nov 14 '18 at 11:34
1
1
Access doesn't offer a built-in way to scroll list boxes. I can write up a WinAPI answer if you're interested, but it will be rather complicated since Access doesn't offer a built-in way to get the hWnd for a form control.
– Erik A
Nov 14 '18 at 11:34
Access doesn't offer a built-in way to scroll list boxes. I can write up a WinAPI answer if you're interested, but it will be rather complicated since Access doesn't offer a built-in way to get the hWnd for a form control.
– Erik A
Nov 14 '18 at 11:34
add a comment |
1 Answer
1
active
oldest
votes
This should work fine:
Dim index As Long
With lstComm
Dim match As Boolean
For index = 0 To .ListCount - 1
If .Column(1, index) = txtSearch.Value Then
match = True
Exit For
End If
Next
If Not match Then Exit Sub
Dim isSelected As Boolean
isSelected = .Selected(index)
.Selected(index) = True
.Selected(index) = isSelected
End With
It retrieves the searched item of the listbox.
If no item has been found it exists.
Otherwise it stores the current selection state of that item, selects it to position the listbox, and restores the stored state of the item.
Selecting and unselecting an item in a listbox does just that, nothing else. It doesn't scroll to the item being selected (for me on Access 2016 using a multi-select list box, at least)
– Erik A
Nov 14 '18 at 12:07
I've tested that before, of course. It scrolled correctly to the position. Works with listbox controlsMulti Select
set toSimple
andExtended
. Microsoft Access 2013.
– Unhandled Exception
Nov 14 '18 at 12:14
On the listbox I'm using (Access 2016 (Office 365), when a row is selected, it's position is being scrolled to.
– user1936588
Nov 14 '18 at 12:14
1
Well, the only thing I can say is that this is undocumented behavior and just doesn't work for me (Build 9126). Your mileage may vary, apparently. If you're going to deploy it, I'd do extensive testing beforehand.
– Erik A
Nov 14 '18 at 12:22
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298879%2fmoving-to-position-of-multi-select-listbox%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This should work fine:
Dim index As Long
With lstComm
Dim match As Boolean
For index = 0 To .ListCount - 1
If .Column(1, index) = txtSearch.Value Then
match = True
Exit For
End If
Next
If Not match Then Exit Sub
Dim isSelected As Boolean
isSelected = .Selected(index)
.Selected(index) = True
.Selected(index) = isSelected
End With
It retrieves the searched item of the listbox.
If no item has been found it exists.
Otherwise it stores the current selection state of that item, selects it to position the listbox, and restores the stored state of the item.
Selecting and unselecting an item in a listbox does just that, nothing else. It doesn't scroll to the item being selected (for me on Access 2016 using a multi-select list box, at least)
– Erik A
Nov 14 '18 at 12:07
I've tested that before, of course. It scrolled correctly to the position. Works with listbox controlsMulti Select
set toSimple
andExtended
. Microsoft Access 2013.
– Unhandled Exception
Nov 14 '18 at 12:14
On the listbox I'm using (Access 2016 (Office 365), when a row is selected, it's position is being scrolled to.
– user1936588
Nov 14 '18 at 12:14
1
Well, the only thing I can say is that this is undocumented behavior and just doesn't work for me (Build 9126). Your mileage may vary, apparently. If you're going to deploy it, I'd do extensive testing beforehand.
– Erik A
Nov 14 '18 at 12:22
add a comment |
This should work fine:
Dim index As Long
With lstComm
Dim match As Boolean
For index = 0 To .ListCount - 1
If .Column(1, index) = txtSearch.Value Then
match = True
Exit For
End If
Next
If Not match Then Exit Sub
Dim isSelected As Boolean
isSelected = .Selected(index)
.Selected(index) = True
.Selected(index) = isSelected
End With
It retrieves the searched item of the listbox.
If no item has been found it exists.
Otherwise it stores the current selection state of that item, selects it to position the listbox, and restores the stored state of the item.
Selecting and unselecting an item in a listbox does just that, nothing else. It doesn't scroll to the item being selected (for me on Access 2016 using a multi-select list box, at least)
– Erik A
Nov 14 '18 at 12:07
I've tested that before, of course. It scrolled correctly to the position. Works with listbox controlsMulti Select
set toSimple
andExtended
. Microsoft Access 2013.
– Unhandled Exception
Nov 14 '18 at 12:14
On the listbox I'm using (Access 2016 (Office 365), when a row is selected, it's position is being scrolled to.
– user1936588
Nov 14 '18 at 12:14
1
Well, the only thing I can say is that this is undocumented behavior and just doesn't work for me (Build 9126). Your mileage may vary, apparently. If you're going to deploy it, I'd do extensive testing beforehand.
– Erik A
Nov 14 '18 at 12:22
add a comment |
This should work fine:
Dim index As Long
With lstComm
Dim match As Boolean
For index = 0 To .ListCount - 1
If .Column(1, index) = txtSearch.Value Then
match = True
Exit For
End If
Next
If Not match Then Exit Sub
Dim isSelected As Boolean
isSelected = .Selected(index)
.Selected(index) = True
.Selected(index) = isSelected
End With
It retrieves the searched item of the listbox.
If no item has been found it exists.
Otherwise it stores the current selection state of that item, selects it to position the listbox, and restores the stored state of the item.
This should work fine:
Dim index As Long
With lstComm
Dim match As Boolean
For index = 0 To .ListCount - 1
If .Column(1, index) = txtSearch.Value Then
match = True
Exit For
End If
Next
If Not match Then Exit Sub
Dim isSelected As Boolean
isSelected = .Selected(index)
.Selected(index) = True
.Selected(index) = isSelected
End With
It retrieves the searched item of the listbox.
If no item has been found it exists.
Otherwise it stores the current selection state of that item, selects it to position the listbox, and restores the stored state of the item.
answered Nov 14 '18 at 11:59
Unhandled ExceptionUnhandled Exception
1,5922610
1,5922610
Selecting and unselecting an item in a listbox does just that, nothing else. It doesn't scroll to the item being selected (for me on Access 2016 using a multi-select list box, at least)
– Erik A
Nov 14 '18 at 12:07
I've tested that before, of course. It scrolled correctly to the position. Works with listbox controlsMulti Select
set toSimple
andExtended
. Microsoft Access 2013.
– Unhandled Exception
Nov 14 '18 at 12:14
On the listbox I'm using (Access 2016 (Office 365), when a row is selected, it's position is being scrolled to.
– user1936588
Nov 14 '18 at 12:14
1
Well, the only thing I can say is that this is undocumented behavior and just doesn't work for me (Build 9126). Your mileage may vary, apparently. If you're going to deploy it, I'd do extensive testing beforehand.
– Erik A
Nov 14 '18 at 12:22
add a comment |
Selecting and unselecting an item in a listbox does just that, nothing else. It doesn't scroll to the item being selected (for me on Access 2016 using a multi-select list box, at least)
– Erik A
Nov 14 '18 at 12:07
I've tested that before, of course. It scrolled correctly to the position. Works with listbox controlsMulti Select
set toSimple
andExtended
. Microsoft Access 2013.
– Unhandled Exception
Nov 14 '18 at 12:14
On the listbox I'm using (Access 2016 (Office 365), when a row is selected, it's position is being scrolled to.
– user1936588
Nov 14 '18 at 12:14
1
Well, the only thing I can say is that this is undocumented behavior and just doesn't work for me (Build 9126). Your mileage may vary, apparently. If you're going to deploy it, I'd do extensive testing beforehand.
– Erik A
Nov 14 '18 at 12:22
Selecting and unselecting an item in a listbox does just that, nothing else. It doesn't scroll to the item being selected (for me on Access 2016 using a multi-select list box, at least)
– Erik A
Nov 14 '18 at 12:07
Selecting and unselecting an item in a listbox does just that, nothing else. It doesn't scroll to the item being selected (for me on Access 2016 using a multi-select list box, at least)
– Erik A
Nov 14 '18 at 12:07
I've tested that before, of course. It scrolled correctly to the position. Works with listbox controls
Multi Select
set to Simple
and Extended
. Microsoft Access 2013.– Unhandled Exception
Nov 14 '18 at 12:14
I've tested that before, of course. It scrolled correctly to the position. Works with listbox controls
Multi Select
set to Simple
and Extended
. Microsoft Access 2013.– Unhandled Exception
Nov 14 '18 at 12:14
On the listbox I'm using (Access 2016 (Office 365), when a row is selected, it's position is being scrolled to.
– user1936588
Nov 14 '18 at 12:14
On the listbox I'm using (Access 2016 (Office 365), when a row is selected, it's position is being scrolled to.
– user1936588
Nov 14 '18 at 12:14
1
1
Well, the only thing I can say is that this is undocumented behavior and just doesn't work for me (Build 9126). Your mileage may vary, apparently. If you're going to deploy it, I'd do extensive testing beforehand.
– Erik A
Nov 14 '18 at 12:22
Well, the only thing I can say is that this is undocumented behavior and just doesn't work for me (Build 9126). Your mileage may vary, apparently. If you're going to deploy it, I'd do extensive testing beforehand.
– Erik A
Nov 14 '18 at 12:22
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298879%2fmoving-to-position-of-multi-select-listbox%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Access doesn't offer a built-in way to scroll list boxes. I can write up a WinAPI answer if you're interested, but it will be rather complicated since Access doesn't offer a built-in way to get the hWnd for a form control.
– Erik A
Nov 14 '18 at 11:34