Solved

Saving  selected data from list box as a variable

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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 …
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…

895 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

11 Experts available now in Live!

Get 1:1 Help Now