Page 1 of 1

ON CHANGE help

PostPosted: Sun Dec 03, 2006 12:42 am
by Jeff Barnes
Hi Everybody,

I am having a problem using the "ON CHANGE" clause of a get.

I want the program to run a function as the user enters data so I tried:

Code: Select all  Expand view
      REDEFINE GET oGetLast VAR cLastName ID 101 OF oSearch  ON CHANGE UpDateSearch() UPDATE


For some reason nothing appears in the get and if I do a MsgInfo( cLastName) it shows that no value was stored to cLastName.

If I change the ON CHANGE to a VALID (and leave the field) my function works fine but I want to check as the user types.

Any Ideas?

Thanks

Jeff

PostPosted: Sun Dec 03, 2006 3:06 am
by Armando
Jeff:

Perhaps you need an incremental search ?

Regards, Armando

PostPosted: Sun Dec 03, 2006 3:22 am
by Jeff Barnes
Yes ... this is what I am trying to do with a few fields.

Can you point me in the right direction?

Jeff

PostPosted: Sun Dec 03, 2006 4:20 am
by Armando
Jeff:

I use this one procedure

PROCEDURE Busca(cAlias,cKey,oBrw)
LOCAL nSeekRec := RECNO()
IF GETASYNCKEY(VK_BACK)
cKey := SUBSTR(cKey,1,LEN(cKey)-1)
ENDIF
IF ! (cAlias)->(DBSEEK(cKey,(.T.)))
GO nSeekRec
ENDIF
oBrw:REFRESH()
oBrw:oVScroll:SETPOS(RECNO())
RETURN

And this is the way to call to the procedure

REDEFINE GET aGets[1] VAR cBusca ID 101 OF oDlg UPDATE;
PICTURE "@!K";
ON CHANGE(SELF:ASSIGN(),;
Busca((cAlias),SUBSTR(cBusca,1,SELF:nPos-1)+UPPER(CHR(nKey)),oBrw),oBrw:REFRESH())

Best regards, Armando

PostPosted: Sun Dec 03, 2006 4:26 am
by Armando
Jeff:

I forgot to tell you that the incremental search works on the active index.

Regards, Armando

PostPosted: Sun Dec 03, 2006 6:06 am
by James Bott
Jeff,

Use a DBCombo. It has built in incremental searching. You can use it with a DBF or an array.

See samples\testdbc1.prg for examples.

James