Página 1 de 1

PostEdit controll in the TDBBrowse

Publicado: Jue Jun 14, 2007 11:44 am
por Gejza Horvath
Hi,
the TDBBrowse object is in the Edit() mode. Finishing the edit, I would like to know, if
the changed key already exists in the table. If yes, the message will shown "Key already
exists" and the changes are cancelled. I try the next code in OnPostEdit event:
METHOD DBBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TFormCiselnik
LOCAL lReturn
lReturn := .T.
IF ::oDbfDataSet1:Typ(dsFIELD) <> ::oDbfDataSet1:Typ(dsVAR)
IF ::oDbfDataSet1:Seek(::oDbfDataSet1:Typ(dsFIELD),.F.)
MsgBox("The key is already in the table","PostEdit")
lReturn := .F.
ENDIF
ENDIF
lCanceled := lReturn
RETURN NIL
This method is called in endless loop after ::oDbfDataSet1:Seek() method, and I see this
message in every loop, until the app is terminated from IDE.
Any idea how to realize this behaviour??
Gejza Horvath

PostEdit controll in the TDBBrowse

Publicado: Jue Jun 14, 2007 12:51 pm
por ignacio
Gejza,
Really strange since TBrwCol:PostEdit which is the method that fires
OnPostEdit controls possible recursivity. You can see it in Brwcol.prg at
line 884 aprox.
BTW, try to use the methods TDataset:SaveState( .T. ) and
TDataset:RestoreState( .T. )
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Gejza Horvath" <_hsoftkn@nextra.sk> escribió en el mensaje
news:[email=46710e33@ozsrv2.ozlan.local...]46710e33@ozsrv2.ozlan.local...[/email]
> Hi,
>
> the TDBBrowse object is in the Edit() mode. Finishing the edit, I would
> like to know, if the changed key already exists in the table. If yes, the
> message will shown "Key already exists" and the changes are cancelled. I
> try the next code in OnPostEdit event:
>
> METHOD DBBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TFormCiselnik
> LOCAL lReturn
> lReturn := .T.
>
> IF ::oDbfDataSet1:Typ(dsFIELD) <> ::oDbfDataSet1:Typ(dsVAR)
> IF ::oDbfDataSet1:Seek(::oDbfDataSet1:Typ(dsFIELD),.F.)
> MsgBox("The key is already in the table","PostEdit")
> lReturn := .F.
> ENDIF
> ENDIF
> lCanceled := lReturn
> RETURN NIL
>
> This method is called in endless loop after ::oDbfDataSet1:Seek() method,
> and I see this message in every loop, until the app is terminated from
> IDE.
>
> Any idea how to realize this behaviour??
>
> Gejza Horvath
>

PostEdit controll in the TDBBrowse

Publicado: Jue Jun 14, 2007 1:32 pm
por Gejza Horvath
Thanks Ignacio,
great support,
those two methods does the job.
Gejza