Solved

Update from List Box

Posted on 2011-09-16
7
206 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

746 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

17 Experts available now in Live!

Get 1:1 Help Now