this.sorted=.t. >use products again in 0 >select products >scan > this.addlistitem(allt(products.product)) >endscan >This.Enabled=.t.Every thing is good but:
this.RowSourceType = 3 this.RowSource = "select product,productID"+; " from products"+; " order by product"+; " into cursor crsProducts" This.ColumnCount = 1 && Show only product - but productID is accesible when you need it This.Enabled=.t.After adding a new item, all you need is:
with thisform.myList .Requery() select crsProducts locate for pk = 123 .ListIndex = iif( eof(), 0, recno()) endwithTo check what's selected you might (and IMHO you should) directly use underlying cursor:
lcProduct = crsProducts.Product
luPK = crsProducts.pk
This approach is much more intiutive then using addlistitem IMHO (just think what if you had thousands of records in products and/or while showing only product column you needed to know many fields of it). This is legal for a listbox:this.RowSourceType = 3 this.RowSource = "select product as myProduct,*"+; " from products"+; " order by 1"+; " into cursor crsProducts" This.ColumnCount = 1 && Show only product nameYou still show only product column but have access to any fields you might need.