Using a ListBox. In VB I would assign a tag to a row for lookups.
So, I did this:
ListBox1.AddRow(data.IdxField(2).StringValue, data.IdxField(4).StringValue, data.IdxField(5).StringValue, data.IdxField(6).StringValue)
ListBox1.RowTag(Listbox1.LastIndex)=data.idxfield(1)
idxfield(1) = my SQL Row ID
When I do a MsgBox - It shows me the value.
Now, when I double click on a row, I need to get this RowTag value. It seems I might need to first get this into a public variable in ListBox.SelectionChanged. Then trigger the DoubleClick method.
Adding this code to SelectionChanged always results in an empty value.
Dim row As Integer
row=Me.RowFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top)
If row<0 Or row>Me.ListCount-1 Then Exit Sub
Me.ListIndex=row
msgbox me.rowtag(row)
You don’t need to manually change the listindex in the double click event since it will already be assigned before that fires. In the doubleClick event you can simply use:
if me.listindex<>-1 then
theSelectedRowTag=me.rowtag(me.listindex)
end if
Back up a step. You’re saving IdxField(1), which is a DatabaseField that is embedded in a recordset. In other words, your saving a pointer to some object whose value may either get destroyed or modified by the time you retrieve it. Save the value instead.
It looks like you’re trying to assign the database field as the rowtag. You need to pick something that can properly be stored/called as a variant, such as the idxField.value to assign to the rowtag to properly call back from it later.
I should have picked up on that since we are using string value to place data in the list box in the first place. Thank you all so much and Happy New Year.