Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 2nd, 2014, 08:18 PM
Registered User
 
Join Date: Jan 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default ListBox-Rows Not Displaying Selected-State Correctly After Many VBA Requeries

LISTBOX, NOT GRID!

Access 2010 Desktop

this is very weird (and urgent).

when i select rows in a ListBox control on a form, using access vba, some rows behave exactly the opposite of how they're supposed to behave-- they APPEAR unselected when i select them, and selected when i unselect them.

Code:
oListBox.Selected(lngRow) = True
However, when i check their Selected property with VBA they return the expected value (meaning the row Selected value is TRUE if i set it to TRUE, if tho it LOOKS UNselected).

Code:
Print oListBox.Selected(lngRow)
->True
video:
youtu.be/Ae0adXdmT48

It seems that the more times i requery the listbox, the worse the problem gets.

Code:
oListBox.Requery
This problem seems unrelated to the number of times i select rows. Only seems related to multiple requeries. At first, it does not happen. Then with repeated requeries, the problem gets progressively worse.

Note, 'Row Source Type' is set to 'Table/Query'. 'Multiselect' is set to 'Simple'.

i'm not using the "Form_" syntax anyplace (which can created unintended instances of forms).

not sure if relevant, but this listbox source-query contains a vba function in a module, which in turn calls the code-behind of another form.

help!

note, i may post this question on other MS Access forums, so plz only answer in one place. thx!

Last edited by johnywhy; March 2nd, 2014 at 09:19 PM.. Reason: meant ListBox, not Grid
 
Old March 3rd, 2014, 12:59 PM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

Cross posted here: http://www.vbaexpress.com/forum/show...855#post305855
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015
 
Old March 4th, 2014, 01:03 AM
Registered User
 
Join Date: Jan 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sample DB

here's a stripped-down access db, containing only the objects and code necessary to duplicate the issue.

https://drive.google.com/folderview?...WVMTWdvd1FaMEk

let me know if you cannot open this.

i think it might be a problem with my display driver.
 
Old March 4th, 2014, 07:34 AM
Registered User
 
Join Date: Jan 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Possibly Solved. Possible Microsoft Access Bug.

i think i solved this.

Problem: when VBA selects all rows in a listbox every time the listbox is requeried, selection behavior gets wonky: some selected rows do not appear selected.

Demo of problem:
https://drive.google.com/file/d/0B8F...lh4SDcyUk11bWc

instructions:
https://docs.google.com/document/d/1...avxFRMocvOZ1RY

the fix is to UNselect all rows in the target table before requerying it.

Produced wonky selection behavior:
1. ListBox Where condition changes
2. Requery ListBox
3. Select All ListBox Rows
4. Repeat

Fixed wonky selection behavior:
1. ListBox Where condition changes
2. UNselect All ListBox Rows
3. Requery ListBox
4. Select All ListBox Rows
5. Repeat

see debug-fix
https://drive.google.com/file/d/0B8F...3FucTZ0Qm15ekE

i think this might be a Microsoft Access Bug, because the behavior (selected rows appearing unselected) is abnormal.

i'll mark this thread solved, after anybody confirms my fix works.

thx!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Hello World App Not Displaying Correctly Ouroboros BOOK: Beginning Android 4 Application Development 1 January 1st, 2013 06:54 PM
Ajax ComboBox not displaying item list correctly tomturner22 BOOK: ASP.NET AJAX Programmer's Reference : with ASP.NET 2.0 or ASP.NET 3.5 ISBN: 978-0-470-10998-4 0 July 26th, 2010 11:25 AM
Views not displaying correctly deanf7 BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 3 March 16th, 2009 09:53 AM
re: DataGrid Selected Item from outside grid vids ASP.NET 1.x and 2.0 Application Design 1 May 2nd, 2005 04:12 PM
Print selected rows mega Excel VBA 1 December 15th, 2004 11:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.