Topic: Trying to use OnAfterClick with a button

Hello,
I have an application where I am using the action to show the selected record in a table in order that it can be edited. I have also added a line of code for the same Edit button in the OnAfterClick event. This line of code is:
Contact.Edit4.Text := 'Hello';
Contact is the form being opened for editing.
I thought this would mean that when the user clicks the edit button, the record would appear in the normal way for editing and then my line of code would be executed and place the word Hello in a field. The record does correctly appear for editing but my line of code does not seem to be executed. Have I completely misunderstood what is meant by OnAfterClick??
Thanks in advance, David.

Re: Trying to use OnAfterClick with a button

Hi David,
As I understand it (which could be wrong), the problem with OnAfterClick is as control passes from your previous form to the Contact form.
It should work if you attached your code to the contact_OnShow event for the Contact form instead. 
However, I'm not sure if that would be okay with how you want your form to work (although you could make it conditional on the action (ie if a new record, don't show the message, otherwise show the message etc).
Derek.

Re: Trying to use OnAfterClick with a button

Hello Derek,
thank you for the response. Yes I did have it working with contact_OnShow but I wanted to attach it only to the Edit button. This is what I wanted to do. When a user clicks edit, the record would appear and write a value into a field (possibly not visible) and then quickly save the record then open it again causing it to save the value. If another user opens the same records, a script would read the invisible field and advise the user the record is already open and so disable the save button for the second user. The aim is prevent clashes of concurrent edits. I would also need to work out the logic of writing another value back to the record when the original user presses save or cancel to indicate is is no longer opened. I am using version 2.3 and it is SQLite. Keeping to SQLite will simplify deployment nicely. I hope all this makes sense.
Thanks again and any ideas appreciated.
David

Re: Trying to use OnAfterClick with a button

radsoft
Example:

procedure Contact_OnShow (Sender: string; Action: string);
begin
    if Action = 'ShowRecord' then Contact.Edit4.Text := 'Hello';
end;
Dmitry.