Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old June 5th, 2007, 09:52 AM
Authorized User
Points: 82, Level: 1
Points: 82, Level: 1 Points: 82, Level: 1 Points: 82, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can I Reference Value in Listbox

Hi,
I've been struggling with this seemingly simple problem for two days now!! How can I reference a value in a listbox? Nothing I try seems to work!! This is my current code:
 Me!lstCheckOut.SetFocus
 Me!lstCheckOut.Selected(0) = True
 data = lstCheckOut.ItemData(0)
 MsgBox data

Please help if you can.
Thanks,
Dave

  #2 (permalink)  
Old June 6th, 2007, 06:49 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you tried Me.lstCheckout.Column(0)? Column(0) being the bound column of the listbox, ie. if column 1 is bound it would be Column(1). Or you might do something like this:

Sub Private SomeButton_Click()

Dim strCheckout As String

strCheckout = Me.lstCheckout.Column(0)

MsgBox (You have selected " & strCheckout & " from the listbox!")

End Sub

Hope that helps!
  #3 (permalink)  
Old June 6th, 2007, 06:53 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In regard to my previous post, the column doesn't have to be bound in the listbox for that to work. If the listbox had three columns, you could do that to get the selected value for any of the three.
  #4 (permalink)  
Old June 6th, 2007, 10:12 AM
Authorized User
Points: 82, Level: 1
Points: 82, Level: 1 Points: 82, Level: 1 Points: 82, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Mccoy. I was neglecting to reference the columns.



Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple Listbox values in another listbox terryv Excel VBA 0 June 27th, 2007 07:01 AM
How can I Reference Value in Listbox dlandolin Access 3 June 5th, 2007 11:06 AM
get reference name demac43 Excel VBA 2 November 20th, 2006 02:35 PM
in need of reference! alialibidad ASP.NET 2.0 Professional 0 June 3rd, 2006 04:11 PM
I'm back :) Listbox var from listbox MichaelTJ .NET Web Services 2 October 21st, 2003 07:06 PM





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