Solved

Getting a data value from a list box in Access

Posted on 2007-04-04
7
225 Views
Last Modified: 2010-04-23
I have a list box that's based on a query.  When the user selects an item from the list box, how to I obtain the value of the item selected.  Specifically, the first item in the list box contains the primary key of a table.  When the user selects the item in the list box, I want to assign the row's PK to a variable.  Any suggestions are appreciated!  Thanks!
0
Comment
Question by:christopher_perry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 18853563
Assuming the PK is in the first column:

YourVariable = me.lstYourListbox.column(0)

0
 
LVL 61

Expert Comment

by:mbizup
ID: 18853572
(add that code to the double-click event of the listbox, or to another event)
0
 
LVL 13

Expert Comment

by:adraughn
ID: 18853574
You should have the Bound Column (in properties) of the list box set to 1, if the PK is the first item. You can then assign it to a variable by using something like:

i = me.lstMyLstBox.value

adria
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:christopher_perry
ID: 18853723
mbizup - Worked great.  Thank you.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 18853735
Glad to help :)
0
 

Author Comment

by:christopher_perry
ID: 18853756
mbizup - Worked great.  Thank you.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 18853767
Lol!  You're welcome :-)
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question