Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 December 27th, 2005, 01:31 PM
Authorized User
Join Date: Dec 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select an particular item when a listbox opens?

1) I have a listbox of names which is populated by one of several queries, selected by VBA according to the user's selection on a form. I want to fix it so that when the listbox opens the item highlighted is the first name alphabetically. I wrote code which identifies the correct name, the problem is that I can't find how to make the list box select it.

2)I was surprised to find that the requery method seems to have no effect while the action works just fine - any clues to why that is?

Me.lstPicklist.Requery 'This method doesn't have any effect
DoCmd.Requery "lstPicklist" 'This works fine


Old December 27th, 2005, 06:50 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts

Hi Alastair,

lstListBox.Selected(0) = True

lstListBox.Selected(1) = True, would highlight the second item in the list, and so on.



Old December 29th, 2005, 06:04 PM
Authorized User
Join Date: Dec 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks, that's got it. As for the other problem, I think there's something weird with the form so I'm going to start over.

Similar Threads
Thread Thread Starter Forum Replies Last Post
ListBox Item selection caterpillar ASP.NET 1.0 and 1.1 Professional 1 July 26th, 2006 12:50 PM
select statement with listbox item(where qnsID =" Astro VB How-To 2 August 31st, 2005 02:12 AM
One item in Listbox venterjo General .NET 2 February 1st, 2005 05:45 AM
How to get selected Item from Listbox? Iceman571 ADO.NET 1 March 25th, 2004 06:33 AM
listbox, different color for each item? MichaelTJ ADO.NET 1 November 13th, 2003 10:37 PM

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