p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access VBA (http://p2p.wrox.com/forumdisplay.php?f=80)
-   -   listbox selection (http://p2p.wrox.com/showthread.php?t=30689)

jon23d June 21st, 2005 12:34 PM

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.



Kevinsharrison June 21st, 2005 01:35 PM

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

All times are GMT -4. The time now is 07:44 AM.

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