filling combo box

Lacroix

New Member
Hi,

I'm trying to fill a combo box with tabledata.
I've got a table containing an id, a first name and a last name.

The result should be, that the user can select a name in the combobox and that the corresponding id can be retrieved when he has done so.

Is it necessary to do everything in code, or can it be done automatic?
I've been looking for help sample code in openedge help or via google, but have a hard time doing so.

Any help would be appreciated.
 
Hi, Lacroix.

You can do something like this.

on default-action OF L-list IN FRAME Main DO:
ASSIGN L-list.
L-id = integer(L-list).
end. /* on default-action OF L-list in frame Main */

L-list:DELIMITER IN FRAME Main = "*".
for each Table break by Id:
L-text = first-name + " " + last-name.
if first (Id) then
L-list:LIST-ITEM-PAIRS IN FRAME Main = L-text + "*" +
STRING(Id).
else
L-list:ADD-LAST(L-text, string(Id)) in frame Main.
end.
do on endkey undo, leave:
enable L-list with frame Main.
WAIT-FOR default-action OF L-list in frame Main.
end.
find Table where Id = L-id no-lock no-error.
if not available Table then do:
message "Error".
undo, retry.
end.
 
When I use:

FOR EACH users:
DO WITH FRAME default-frame:
cboName:ADD-LAST(users.name + " " + users.firstname, users.id).
END.
END.

It gives error 8590 for each record:

Ignoring extra argument(s) of <attribute> for <widget id> that is of <LIST-ITEMS> type. (8590)


I don't see the problem, according to help thats a valid use of add-last.
 
You have to tell progress that you want to use pairs insted of the default. So your program should change to this.

FOR EACH users:
DO WITH FRAME default-frame:
if cboName:NUM-ITEMS = 0 THEN
cboName:LIST-ITEM-PAIRS = users.name + " " + users.firstname + string(users.id).
else
cboName:ADD-LAST(users.name + " " + users.firstname, string(users.id)).
END.
END.
 
Understand how they work now, this did the trick:

DO WITH FRAME default-frame:
ASSIGN cboName:LIST-ITEM-PAIRS = ",".
FOR EACH users:
cboName:ADD-LAST(users.name+ " " + users.firstname, STRING(users.id)).
END.
END.
END PROCEDURE.


Thanks for the help.
 
Back
Top