Solved

Getting a data value from a list box in Access

Posted on 2007-04-04
7
222 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
  • 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
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…
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…
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 …

839 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