Solved

Saving  selected data from list box as a variable

Posted on 2014-10-18
2
253 Views
Last Modified: 2014-10-18
I have successfully created a search text box to jump to a record in a list box.

Now I want to store the information from the selected record as variable data to be used in a series of form text boxes.

Here is the code I have so far:

Private Sub lstLeft_Click()
    Dim strName As String
    Dim strEmpID As String
    Dim intItem As Integer
   
    intItem = 0 To lstLeft.ListCount - 1
   
    If lstLeft.Selected(intItem) Then
           TempVars.Add "strName",lstLeft.Column(2, intItem) & ", " & lstLeft.Column(3, intItem)
           TempVars.Add "strEmpID", lstLeft.Column(1, intItem)
    End If
End Sub

The "intItem = 0 To lstLeft.ListCount - 1" is not correct.

I am only "clicking' on one record and then clicking a command button to navigate to the next form.

Thanks

Glen
0
Comment
Question by:GPSPOW
[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
2 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 40388884
<<I am only "clicking' on one record and then clicking a command button to navigate to the next form.>>

  There's no need for the loop then.  The list control itself will contain the value of the bound column.  So you just want to do:

           TempVars.Add "strName",lstLeft.Column(2) & ", " & lstLeft.Column(3)
           TempVars.Add "strEmpID", lstLeft.Column(1)

and watch it; the column property is zero based.

Jim.
0
 

Author Closing Comment

by:GPSPOW
ID: 40388971
Thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

733 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