Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

row source issues

Status
Not open for further replies.

skinicod

Programmer
Sep 9, 2003
46
GB
Hi,

I have an issue when trying to select a value from a list box I have created using the rowsource property. The following code is what I am using to get values from the selected item within my list box:

Private Sub MyList_Click()
For Each varItm In MyList.ItemsSelected
Info1.Caption = MyList.Column(0, varItm)
Info2.Caption = MyList.Column(1, varItm)
Info5.Caption = MyList.Column(4, varItm)
Next
End Sub

The problem is that during this procedure MyList - which is the list box - seems to lose the row source I set earlier. If I restate the rowsource just before my for each loop the procedure at least picks up a selected item, but it always defaults that item to the first in my listbox.

Does anyone have any idea what I am taling about or have a solution??

Cheers,

Skinicod.

PS an example of a RowSource that I would generate earlier in the code is a follows:

MyList.RowSource = "SELECT table, name, value, count, uniqueobs, tab_percentage from audit where table in(" & StrTab & ");
 
You are using varItm two different ways. One as an object and one as the row index. That is the reason you loose it. The .Column(ColNbr, RowNbr) should use a row index.

Private Sub MyList_Click()
For Each varItm In MyList.ItemsSelected
Info1.Caption = MyList.Column(0, varItm)
Info2.Caption = MyList.Column(1, varItm)
Info5.Caption = MyList.Column(4, varItm)
Next
End Sub


---------------------
scking@arinc.com
---------------------
 
But how do you know which row your lokking at, without using varItm? I use this method all the time and it works perfectly as long as I have either set up my own rowsourcetype or have set the rowsource within the form design itself - as opposed to programming in a rowsource - so why should that make any difference anyway?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top