Solved

Getting a data value from a list box in Access

Posted on 2007-04-04
7
224 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

735 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