Bill Benson
vbacreations at gmail.com
Wed Mar 12 17:22:29 CDT 2014
Thanks for the additional commentary which I will surely (? -- well, I hope so anyway) keep in mind for future. Corollary mystery... Is it conceivable that as listbox was not really clearing out, that might by why the .Selected property remained zero even for the item in the highlighted position? This had me baffled for the longest time, then I couldn't reproduce the situation after changing from a Query/Table type rowsource to Value List. Still that doesn't really seem like an explanation for the Selected property being zero for everything, but maybe so... -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Paul Hartland Sent: Wednesday, March 12, 2014 5:46 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Listbox Issue - Selected Property or ListIndex persisting after requery If the listbox is not multi-select then the Me!ListBox = Null should work, if it's a multi-select then you may find you have to loop through the selections and make them false, actually probably better (not sure so open to ideas) to always use the loop, you don;t have to remove the rowsource then, to do this use something like below: Dim intClearSelected As Integer For intClearSelected = 0 To Me!ListBox.ListCount-1 If Me!ListBox.Selected(intClearSelected)=True then Me!ListBox.Selected(intClearSelected)=false Endif Next intClearSelected Paul On 12 March 2014 21:15, David A. GIbson <davidalangibson2010 at gmail.com>wrote: > I have an example at work so it's air code > . > Me! Listbox2=null > Me!Listbox2=requery > > I can send you a solid example tomorrow. > > David GIbson > > > Sent from up the creek... > > -------- Original message -------- > From: Bill Benson <bensonforums at gmail.com> > Date: 03/12/2014 3:44 PM (GMT-06:00) > To: 'Access Developers discussion and problem solving' < > accessd at databaseadvisors.com> > Subject: [AccessD] Listbox Issue - Selected Property or ListIndex > persisting > after requery > > I have written listbox that has Table/Query RowsourceType property. > > I am trying to clear the selection in it by requery. It does not seem to be > working. > > In particular, if the user has selected B out of > > A > B > C > > > Then when I change Rowsource = "" and requery, the listbox contents vanish, > but when I make the rowsource equal to what it was, the selected item is > still selected. > > My concern about this is, what happens if B no longer exists, or the order > of items changes, since I do not have a primary key type data field in the > listbox. > > I could switch to AddItem but that might be slower. > > All I want to do is have nothing selected after a requery. > > Pulling hair out. > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > -- Paul Hartland paul.hartland at googlemail.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com