Topic: Calc Field

Hi All,


I couldn't workout a calculated value field in the attached sample project. Anybody could help please?

I'm using editable tablegrid.
After entering starting value, next day's value need to be increased by x (user defined) percent to have today's value. This need to continue all years or until stopped entries.

Post's attachments

Attachment icon Chain Test.zip 4.83 kb, 15 downloads since 2021-01-10 

Adam
God... please help me become the person my dog thinks I am.

Re: Calc Field

can you provide a sample records/result? 5 records i think would be nice.

brian

Re: Calc Field

Hi Brian,


Thanks a lot for your kind attention.


Here is the new sample project with some records.
If it's easier calculations may be done on form rather than using editable tablegrid.
Also included in the zip file screen cap highlighting calc fields.

Post's attachments

Attachment icon ChainTest2.zip 84.42 kb, 13 downloads since 2021-01-11 

Adam
God... please help me become the person my dog thinks I am.

Re: Calc Field

I have sorted out needed calcs on form (form2) using non editable tablegrid.


However, one thing I couldn't do. I need to copy last entered value on form 1 table grid say column 5 into edit field on form2.
Could anybody write a script to achieve it please?

Adam
God... please help me become the person my dog thinks I am.

Re: Calc Field

Been busy, sorry.
You can get it using query in script. Something like

Form2_OnShow (Sender: TObject; Action: string);
begin
    if Action = 'NewRecord' then
        Form2.EditField.Text := SQLQuery('SELECT `col5` FROM `Chain` ORDER BY `id` DESC LIMIT 1');
end;
brian

Re: Calc Field

brian.zaballa wrote:

Been busy, sorry.
You can get it using query in script. Something like

Form2_OnShow (Sender: TObject; Action: string);
begin
    if Action = 'NewRecord' then
        Form2.EditField.Text := SQLQuery('SELECT `col5` FROM `Chain` ORDER BY `id` DESC LIMIT 1');
end;

Hi Brian,


Thanks a lot for the script, but I get "not enough actual parameters" script error.

Adam
God... please help me become the person my dog thinks I am.

Re: Calc Field

AD1408 wrote:
brian.zaballa wrote:

Been busy, sorry.
You can get it using query in script. Something like

Form2_OnShow (Sender: TObject; Action: string);
begin
    if Action = 'NewRecord' then
        Form2.EditField.Text := SQLQuery('SELECT `col5` FROM `Chain` ORDER BY `id` DESC LIMIT 1');
end;

Hi Brian,


Thanks a lot for the script, but I get "not enough actual parameters" script error.

My Bad, LMAO, change SQLQuery to SQLExecute

brian

Re: Calc Field

Hi Brian,


Still doesn't work for me. I'm adding sample project to see what I'm missing.

Post's attachments

Attachment icon Chain Test2.zip 5.49 kb, 3 downloads since 2021-01-14 

Adam
God... please help me become the person my dog thinks I am.

9 (edited by brian.zaballa 2021-01-14 13:39:05)

Re: Calc Field

It's because you didn't populate col1 in the previous record

Post's attachments

Attachment icon ChainTest3.zip 496.17 kb, 13 downloads since 2021-01-14 

brian

Re: Calc Field

Thank you very much Brian..................
Truly appreciated................

Adam
God... please help me become the person my dog thinks I am.