Board index » delphi » Changes on 'Before Post' event not 'sticking' through post

Changes on 'Before Post' event not 'sticking' through post

I'm using Interbase 5 with Delphi 3.  My problem is that I have a DBMemo

component (attached to a blob text field) I update with text
programmatically on the 'Before Post' event of a particular TTable.  The
updated text  is there in the DBMemo at the end of the 'Before Post'
event, but disappears between the end of
'Before Post' and the beginning of 'After Post'.  It seems that the
updated text was 'rolled back' during the post (Because I change the
content of the control instead of changing the content of the field in
the table directly).  How do I make the changes I made to the DBMemo in
the 'Before Post' event 'stick'
during the post?  Or, put another way, how do I make changes to a text
blob field directly without having to address it through a control like
DBMemo?  I'm sure this is an easy one, but I'm just missing something...

 

Re:Changes on 'Before Post' event not 'sticking' through post


You must make the changes to the field, not the DBMemo control.

In the BeforePost event, build the TStrings statement you want to assign to
your memo field and use the following code.
    Table1.FieldByName('memofield').Assign(mystringlist);

I think this is right.  I'm not sure about the exact syntax, but you must
use the Assign procedure with a memo field.

Quote
Sean McElroy wrote:
> I'm using Interbase 5 with Delphi 3.  My problem is that I have a DBMemo

> component (attached to a blob text field) I update with text
> programmatically on the 'Before Post' event of a particular TTable.  The
> updated text  is there in the DBMemo at the end of the 'Before Post'
> event, but disappears between the end of
> 'Before Post' and the beginning of 'After Post'.  It seems that the
> updated text was 'rolled back' during the post (Because I change the
> content of the control instead of changing the content of the field in
> the table directly).  How do I make the changes I made to the DBMemo in
> the 'Before Post' event 'stick'
> during the post?  Or, put another way, how do I make changes to a text
> blob field directly without having to address it through a control like
> DBMemo?  I'm sure this is an easy one, but I'm just missing something...

Re:Changes on 'Before Post' event not 'sticking' through post


Quote
Yves Parent wrote:

> You must make the changes to the field, not the DBMemo control.

I'd have to look at DB.PAS to absolutely confirm this, but I believe
that the notification to the controls, that they should collect their
data from the screen and post it back to the data-source, has already
occurred when the BeforePost event fires.  Therefore changes made to the
controls will, indeed, not "stick."  Changes made to the fields should
stick.

Re:Changes on 'Before Post' event not 'sticking' through post


In C++ Builder 3, there is a 'Modified' property in all classes derived from
TCustomEdit. You must set it to true if your program makes changes to
something like a TDBEdit. Perhaps this is also true with Delphi?

To quote from the online help for this property:

Indicates whether the user edited the text of the edit control.

__property bool Modified = {read=GetModified, write=SetModified, nodefault};

Description

Use Modified to determine whether the Text property of the edit control
changed. If an application directly alters the Text property of an edit
control, it should set the Modified property to true.

Quote
Sean McElroy wrote in message <357EF60E.49846...@utw.com>...
>I'm using Interbase 5 with Delphi 3.  My problem is that I have a DBMemo

>component (attached to a blob text field) I update with text
>programmatically on the 'Before Post' event of a particular TTable.  The
>updated text  is there in the DBMemo at the end of the 'Before Post'
>event, but disappears between the end of
>'Before Post' and the beginning of 'After Post'.  It seems that the
>updated text was 'rolled back' during the post (Because I change the
>content of the control instead of changing the content of the field in
>the table directly).  How do I make the changes I made to the DBMemo in
>the 'Before Post' event 'stick'
>during the post?  Or, put another way, how do I make changes to a text
>blob field directly without having to address it through a control like
>DBMemo?  I'm sure this is an easy one, but I'm just missing something...

Other Threads