[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

I need to parse list box rows. VBA

Posted on 2008-06-11
6
Medium Priority
?
1,397 Views
Last Modified: 2013-11-28
I have a multiple column list box. I need to iterate through each row and read the column values
What is the syntax?

For example:

Dim intCtr as integer
Dim strCol0Value as string
Dim strCol1Value as string

For intCtr=0 To listbox.Listcount -1
  strCol0Value =  MyValuelistbox (??)
  strCol1Value  MyValuelistbox (??)

Next intCtr

Or can I declare listbox items ?

For each item in listbox
   strCol0Value=??
   strCol0Value=??
Next item

thanks
0
Comment
Question by:Dovberman
  • 3
  • 3
6 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 21764588
Dovberman,

Why not just iterate through the Listbox's source Table (or Query)?

What exactly are you trying to accomplish here?

JeffCoachman
0
 

Author Comment

by:Dovberman
ID: 21767453
The source is a value list. There are 2 list boxes. One contains all available choices. The other contains the choices that were selected from list 1.

I need to update a table based on the items in list 2.
0
 

Author Comment

by:Dovberman
ID: 21767477
I found code for parsing and finding selected rows. Since all rows need to be read, I can remove the selected criteria.

  For intCtr = 0 To lstApplicants.ListCount - 1
        'isSelected = lstApplicants.Selected(intCtr)
        'If isSelected Then
             lstApplicants.ItemData (intCtr) ' returns the data from column 0
            'Do Stuff
        End If
     Next
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 1000 total points
ID: 21770047
Dovberman,

If this is a multi-select listbox, you can use code like this to "de-select all the selected rows:

Dim varItem As Variant
Dim ctl As Control

Set ctl = Me.lstCustomers

    'Loops through all the Items and turns them off
    For Each varItem In ctl.ItemsSelected
        ctl.Selected(varItem) = False
    Next varItem

You will have to modify the object names to match yours.

JeffCoachman
0
 

Author Closing Comment

by:Dovberman
ID: 31466320
Thanks for the extra information
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 21774678
;-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

834 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