Página 1 de 1

Dataset - Cancel not allowed

Publicado: Sab Jun 23, 2007 7:23 am
por Gejza Horvath
Hi,
I have a DBBrowse and DBNavigator linked to DbfDataset. All operations like Append,
Delete,Edit and navigation are OK. I have a problem, when the browser is in append or edit
mode. Pressing the Cancel button on the DBNavigator in this moment, I get this message
from dataset:
Invalid use of 'Cancel', set must be on 'Edit' or 'AddNew' mode[#0]
On procedure: TDDBROWSE:CANCELEDIT line 1041.
and the changes (or new record) are saved. When I teminate the edit process pressing the
ESC key, it works like excepted: changes are lost, record is not saved.
In the DBNavigator are defined:
:OnClickEdit := {|| ::oDBBrowse1:Edit()}
:OnClickInsert := {|| ::oDBBrowse1:Append()}
What is the reason of this behaviour and how to avoid it?
Gejza

Dataset - Cancel not allowed

Publicado: Sab Jun 23, 2007 7:27 am
por Gejza Horvath
I get the same message pressing the Update button.
Gejza

Dataset - Cancel not allowed

Publicado: Sab Jun 23, 2007 8:38 pm
por ignacio
Gezja,
The TDBBrowse object is not mean to be used with TDBNavigator directly.
BTW, here is the code to make it work:
//---------------------------------------------------------- --------------------
METHOD DBNavigatorClickDelete( oSender ) CLASS TFrm
WITH OBJECT ::oDataSet
:Delete()
END WITH
RETURN .F.
//---------------------------------------------------------- --------------------
METHOD DBNavigatorClickInsert( oSender ) CLASS TFrm
::oDbBrowse:Append()
oSender:UnLock()
RETURN .F.
//---------------------------------------------------------- --------------------
METHOD DBNavigatorClickEdit( oSender ) CLASS TFrm
::oDbBrowse:Edit()
oSender:UnLock()
RETURN .F.
//---------------------------------------------------------- --------------------
METHOD DBNavigatorClickUpdate( oSender ) CLASS TFrm
::oDbBrowse:CancelEdit()
RETURN .F.
//---------------------------------------------------------- --------------------
METHOD DbBrowsePostEdit( oSender, lCanceled, nKey ) CLASS TFrm
::oDbNavigator:Lock()
RETURN Nil
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Gejza Horvath" <_hsoftkn@nextra.sk> escribió en el mensaje
news:[email=467cae75@ozsrv2.ozlan.local...]467cae75@ozsrv2.ozlan.local...[/email]
> Hi,
>
> I have a DBBrowse and DBNavigator linked to DbfDataset. All operations
> like Append, Delete,Edit and navigation are OK. I have a problem, when the
> browser is in append or edit mode. Pressing the Cancel button on the
> DBNavigator in this moment, I get this message from dataset:
>
> Invalid use of 'Cancel', set must be on 'Edit' or 'AddNew' mode[#0]
> On procedure: TDDBROWSE:CANCELEDIT line 1041.
>
> and the changes (or new record) are saved. When I teminate the edit
> process pressing the ESC key, it works like excepted: changes are lost,
> record is not saved.
>
> In the DBNavigator are defined:
>
> :OnClickEdit := {|| ::oDBBrowse1:Edit()}
> :OnClickInsert := {|| ::oDBBrowse1:Append()}
>
> What is the reason of this behaviour and how to avoid it?
>
> Gejza
>