Solved

Saving  selected data from list box as a variable

Posted on 2014-10-18
2
254 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 58

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

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.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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 different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

726 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