Wrox Programmer Forums
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 June 21st, 2005, 12:34 PM
Registered User
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default listbox selection

Good afternoon,

I have two problems I can't seem to figure out, both regarding a listbox.

I have a listbox that is populated with several different fields. Here is the sql I use to populate the box:

SELECT DepartmentGoals.DepartmentGoalID, DepartmentGoals.Name, DepartmentGoals.Importance, DepartmentGoals.Open FROM DepartmentGoals ORDER BY [Open], [Importance], [Name];

What I want to do is: when the form containing the box opens select a particular listing (via the DepartmentGoals.DepartmentGoalID field) in the listbox.

Also, when a user clicks on a new list in the box I want to trigger an event that will extract the DepartmentGoals.DepartmentGoalID selected from the listbox.

I cannot seem to find the property or method to access this information though. Any help would be greatly appreciated.



Old June 21st, 2005, 01:35 PM
Registered User
Join Date: Apr 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Kevinsharrison

I think this is what you want, this is how I have done this in the past. I use the double click event. Then it will take the data of the bound column. Then i would open another form based on the info. I think that is what you are trying to do.

Private Sub listbox_DblClick(Cancel As Integer)
Dim strlstData As String
Dim strCriteria As String
Dim i

For Each i In lstStnBOAll.ItemsSelected
  strlstData = lstStnBOAll.ItemData(i)

strCriteria = "[Broadcast_Num]= " & strlstData
DoCmd.OpenForm "frmBroadcastorder", , , strCriteria

End Sub

Similar Threads
Thread Thread Starter Forum Replies Last Post
About listbox selection mode chandra_yvr ASP.NET 2.0 Basics 1 April 3rd, 2007 07:50 AM
ListBox Item selection caterpillar ASP.NET 1.0 and 1.1 Professional 1 July 26th, 2006 12:50 PM
ListBox Value Selection problem caterpillar General .NET 0 July 26th, 2006 11:41 AM
Multiple Selection of Listbox jasminecyriac ASP.NET 2.0 Basics 0 June 22nd, 2006 05:20 AM
Listbox selection in a form jpcoutts Access 1 November 10th, 2004 05:02 PM

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