Solved

Saving  selected data from list box as a variable

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now