Solved

Update from List Box

Posted on 2011-09-16
7
236 Views
Last Modified: 2012-05-12
Dear Experts,

I have a multi select list box which updates a record with the ID of the items selected in the list box - this is bound to column 1 & works all fine (code below)

However I need the list box to update 2 different fields ...

[Tickers] to be updated with CategorySelect.BoundColumn = 1 (which is already in the code)

[TickersName] to be updated with CategorySelect.BoundColumn = 2

Can anybody help?

 
Private Sub CategorySelect_AfterUpdate()
Ticker = "24, "
CategorySelect.BoundColumn = 1
For Each Item In CategorySelect.ItemsSelected
    Ticker = Ticker + CategorySelect.ItemData(Item) + ", "
       
Next Item
End Sub

Open in new window

0
Comment
Question by:correlate
  • 5
  • 2
7 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 36548112
Give this a try:

Private Sub CategorySelect_AfterUpdate()
Ticker = "24, "
CategorySelect.BoundColumn = 1
For Each Item In CategorySelect.ItemsSelected
    Ticker = Ticker + CategorySelect.ItemData(Item) + ", "
    TickerName = CategorySelect.Column(1).ItemData(Item)      
Next Item
End Sub 

Open in new window

Please note that column indexes are zero based, so the first column is 0, second is 1, etc.  Adjust the code accordingly if needed.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36548151
Sorry - my syntax is off.

This should do it:

Private Sub CategorySelect_AfterUpdate()
Ticker = "24, "
CategorySelect.BoundColumn = 1
For Each Item In CategorySelect.ItemsSelected
    Ticker = Ticker + CategorySelect.ItemData(Item) + ", "
    TickerName = CategorySelect.Column(1,item) 
Next Item
End Sub 

Open in new window



Again, veriry that the zero-based column number is correct (I'm using 1, assuming were talking about the column that appears second).
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 36548155
To concatenate tham as you are doing with Ticker:

TickerName = TickerName + CategorySelect.Column(1,item) + ", "

Open in new window

0
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!

 

Author Comment

by:correlate
ID: 36548162
Hi mbizup

Alas no luck, I tried a few variations on theis by I'm getting a run-time error 424 - object required
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36548179
Can you post your current code?

The syntax I have here http:#a36548151 worked for me (tested) with a multi-select listbox.

Me.ListboxName.Column(ColumnNumber,RowNumber)

(substituting Item for RowNumber)
0
 

Author Closing Comment

by:correlate
ID: 36548181
Brilliant, Thank you our replies got crossed in the post

Mnay thanks
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36548192
Glad to help out :-)
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2010 7 41
access to sql migration 5 23
access query filter for lower case lett 7 20
Append Query Access 2010 4 23
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

756 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