Solved

Update from List Box

Posted on 2011-09-16
7
223 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

770 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