Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Getting a data value from a list box in Access

Posted on 2007-04-04
7
Medium Priority
?
227 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

704 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