combo box and database

rzr

Member
You could try the below

Code:
[FONT=courier new]DEFINE VARIABLE cListItems AS CHARACTER NO-UNDO.
DEFINE VARIABLE cName AS CHARACTER LABEL "Custome Name" 
    VIEW-AS COMBO-BOX 
    SIZE 30 BY 20 
    SORT
    DROP-DOWN-LIST
    AUTO-COMPLETION
    NO-UNDO.

FORM cName WITH FRAME FrMyFrame SIDE-LABELS.

cListItems = "".

FOR EACH Customer NO-LOCK:

    IF cListItems = "" THEN cListItems = Customer.NAME.
    ELSE cListItems = cListItems + "," + Customer.NAME.

END.

ASSIGN cName:LIST-ITEMS IN FRAME FrMyFrame = cListItems.
ENABLE cName WITH FRAME FrMyFrame.
WAIT-FOR "CLOSE" OF THIS-PROCEDURE.[/FONT]
 
maybe these code is you wanted .

def var i as char view-as combo-box
LIST-ITEMS "a","b" ,"c" .
form
i
with frame one .

........ get data from your table .
for each your table:
i:insert(table.field1,"a").
end.
update i with frame one .
 

TomBascom

Curmudgeon
It's amazing what you can find in the docs.

For instance, the documentation for the COMBO-BOX phrase contains an example of populating a combo-box from a database table:

Code:
DEFINE VARIABLE ix                AS INTEGER     NO-UNDO.
DEFINE VARIABLE rep             AS CHARACTER NO-UNDO LABEL "Rep"   VIEW-AS COMBO-BOX.
DEFINE VARIABLE temp-string AS CHARACTER NO-UNDO.

FORM rep WITH FRAME main-frame SIDE-LABELS.

ON ANY-PRINTABLE OF rep DO:  /* Find the first entry in the drop‑down list that begins with the character typed. Set the SCREEN-VALUE of the combo box to that value. */

  seek-item:  DO ix = 1 TO SELF:NUM-ITEMS:
    IF SELF:ENTRY(ix) BEGINS LAST-EVENT:FUNCTION THEN DO:
      SELF:SCREEN-VALUE = SELF:ENTRY(ix).
      LEAVE seek-item.
    END.
  END.
  IF ix > SELF:NUM-ITEMS THEN BELL.

END.

ON CURSOR-DOWN OF rep DO:  /* Change the SCREEN-VALUE of the combo box to the next value from the drop‑down list. */

  ix = SELF:LOOKUP(SELF:SCREEN-VALUE).
  IF ix < SELF:NUM-ITEMS THEN
    SELF:SCREEN-VALUE = SELF:ENTRY(ix + 1).

END.

ON CURSOR-UP OF rep DO:  /* Change the SCREEN-VALUE of the combo box to the prev value from the drop‑down list. */

  ix = SELF:LOOKUP(SELF:SCREEN-VALUE).
  IF ix > 1 THEN
     SELF:SCREEN-VALUE = SELF:ENTRY(ix - 1).

END.

temp-string = "".

FOR EACH Salesrep NO-LOCK:
  temp-string = IF temp-string = "" THEN SalesRep.SalesRep ELSE temp-string + "," + SalesRep.SalesRep.
END.

ASSIGN rep:LIST-ITEMS IN FRAME main-frame = temp-string.
ENABLE rep WITH FRAME main-frame.
 
Top