Solved

Update from List Box

Posted on 2011-09-16
7
244 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
[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
  • 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
Revamp Your Training Process

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

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

728 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