Solved

Update from List Box

Posted on 2011-09-16
7
230 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

840 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