yronium Level: Moderator

 Registered: 14-04-2002 Posts: 907
|
Re: Control Required
Hello. I didn't understand: is the Abbr field in relation with another lookup table?
Anyway, there's nothing wrong using the listbox control. The steps, assuming that you use ADO, are like following:
- load a recordset
- sort it (this sorting has to be done on the recordset because you load a built string into the listbox), by the Sort property
- for each record you build a string with the Abbr value and the Rem value
- add the string to the listbox by the AddNew method
- (Important) set a number for each string by the ItemData property. This property is useful to set an ID to each list item, and you can set it by, after the lstMyList.AddNew itemstring method, an instruction like lstMyList.ItemData(lstMyList.NewIndex) = ID
- later you can read the ItemData property in the Click event, and choose a record in the table according with the selected item.
You can even use a DataList/DataCombo control instead. These controls are designed to work with a recordset and expose some more useful properties to bind them to the tables. The bad news is that they don't work in unbound mode, so if you want to do it you should use the common Listbox control. But I'd use it anyway: it's the first control you chose, so you are looking for something like it, and I think the best way is to make it work. Since I discovered the ItemData property I definitely chose to use listboxes and combos in my db-based projects.
Hope is clear. If you need some more info, tell us.
____________________________
Real Programmer can count up to 1024 on his fingers
|