1 (edited by kim143 2017-06-01 12:59:31)

Topic: When I create First Child Record With Condition error

Hello community little bit stuck here

When I create First Child Record in "sub_" table With Conditions error occurs "from child (sub) to ==>> grand - child (sub_)"

---------------------------
tgrid
---------------------------
Could not convert variant of type (UnicodeString) into type (Double)
---------------------------
OK   
---------------------------

as shown in gchild1.png

as @Dmitry suggested that I should use valve and sqlvalue insted of text and dbitemid in this post http://myvisualdatabase.com/forum/viewtopic.php?id=3375 

at first it was working fine but when I divided relationship further I was not able to divide it correctly.

It seems like calculated field in "sub_" table also misbehaves don't know why  hmm

in image gchild.png

Also sometimes when I copy one code from one example project to another this kind of error occurs and software freezes.

---------------------------
tgrid
---------------------------
Access violation at address 00000000. Read of address 00000000.
---------------------------
OK   
---------------------------


images are in folder name "images" attached with sample project thanks for the help smile

edit
-----------
attached new project

Post's attachments

Attachment icon releted_tgrid2.zip 37.33 kb, 572 downloads since 2017-06-01 

Re: When I create First Child Record With Condition error

Try to change this event

procedure Form3_Button2_OnClick (Sender: string; var Cancel: boolean);
begin
  if form3.edit1.Value + sqlexecute('select TOTAL(gram) from sub where id_tab_in =' +form3.combobox1.sqlValue) > sqlexecute('select grams from tab_in where id ='+form3.combobox1.sqlValue) then showmessage ('Not Allowed');
  if form3.edit1.Value + sqlexecute('select TOTAL(gram) from sub where id_tab_in =' +form3.combobox1.sqlValue) <= sqlexecute('select grams from tab_in where id ='+form3.combobox1.sqlValue) then form3.button1.click;
end;
Dmitry.

3 (edited by kim143 2017-05-31 17:37:37)

Re: When I create First Child Record With Condition error

I changed code but it still gives error
when I create new child record.in "Child (sub)" table it works but when I create next child record in "Grand-Child(Sub_)" it gives error only when its first record.
///EDIT

Also I attached project again, after changing code but its still not working for    "Grand-Child(Sub_)"

Please follow Numbers (Steps) to create same error

Post's attachments

Attachment icon child error with steps.png 41.62 kb, 433 downloads since 2017-05-31 

Re: When I create First Child Record With Condition error

kim143
This error mean, that you have empty variable which you try to convert to number type. Example, your SQLExecute statement return nothing, but you try use it for mathematical operations in Form4_Button1_OnClick

Dmitry.

5 (edited by kim143 2017-06-01 13:02:22)

Re: When I create First Child Record With Condition error

Hello @Dmitry thanks for solution I used TOTAL instead of sum and it solved issue, but I am still stuck at second issue calculated value from (sub_)  Pending value is not working properly don't know why, can you please give it a look? Attached New Sample Also

Here is the code what I am using for calculated field

(
(SELECT sub.gram FROM sub WHERE sub.id=sub_.id_sub)                 
-   
(SELECT TOTAL(ifnull(s.gram1, 0))+TOTAL(ifnull(s.gram2, 0))+TOTAL(ifnull(s.gram3, 0)) FROM sub_ s WHERE (s.id_sub=sub_.id_sub) AND (s.record_count <= sub_.record_count )) 
)

thanks  @Dmitry

Post's attachments

Attachment icon gchild.png 32.96 kb, 419 downloads since 2017-06-01 

Re: When I create First Child Record With Condition error

kim143
Unfortunately I also stuck, this calculated field work if you try to addition these sub queries


(
(SELECT sub.gram FROM sub WHERE sub.id=sub_.id_sub)                 
+ 
(SELECT TOTAL(ifnull(s.gram1, 0))+TOTAL(ifnull(s.gram2, 0))+TOTAL(ifnull(s.gram3, 0)) FROM sub_ s WHERE (s.id_sub=sub_.id_sub) AND (s.record_count <= sub_.record_count )) 
)

but don't work for subtraction.


Maybe this is some kind of specificity of SQLite.

Dmitry.

Re: When I create First Child Record With Condition error

asked on stackoverflow here is the answer never thought about "real" will have this kind of effect on the values

https://stackoverflow.com/questions/443 … -in-sqlite