Hello friends,

I have the following script. When i run it the first time, everything works perfectly, however when i close the form and try to open another record it gives me the following error:


Error:

Attached image


Script:

var
     amountofdays: integer;

begin

      amountofdays:= SQLExecute('SELECT paymentterm FROM client WHERE id='+ IntToStr(frmAddInvoice.ComboBox2.dbItemID) );
          
          if amountofdays = 0
              then
              amountofdays:= 8;

      frmAddInvoice.DateTimePicker2.DateTime := frmAddInvoice.DateTimePicker1.DateTime + amountofdays;

      frmAddInvoice.Edit4.Text := IntToStr(amountofdays);

end;

Could somebody point out what i am doing wrong?

Thank you sibprogsistem! Made a few changes and it works perfectly!

Thank you sibprogsistem! It works now.


Do you know the syntax to save DBImage by script? When i use this:


procedure frmMain_Button12_OnClick (Sender: TObject; var Cancel: boolean);
begin
       SQLExecute('UPDATE table SET name="'+frmMain.Edit1.Text+'",logo = "frmMain.DBImage1.Picture" WHERE id= 1');
end;

the value entered in SQLite is just "frmMain.DBImage1.Picture" which is wrong.

Hello friends,


I have the following script, i want to load some values and an image, in my following test script the value is loaded but the image does not show up. According to sqlitestudio there is a blob value in the image field of the table (logo and logo filename have values). Does anyone see why the image is not loaded?


procedure frmMain_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
       frmMain.Edit1.Text := SQLExecute('SELECT name FROM table where id = 1');
       frmMain.DBImage1.LoadFromDatabase('table', 'logo', 1);
end;

Also, i am trying to update these values by script, in my following test script the text values are saved just fine, but the dbimage file does not update:


procedure frmMain_Button12_OnClick (Sender: TObject; var Cancel: boolean);
begin
       SQLExecute('UPDATE table SET name="'+frmMain.Edit1.Text+'",logo = "frmMain.DBImage1.Picture" WHERE id= 1');
end;

Thanks in advance

30

(7 replies, posted in Reports)

sibprogsistem wrote:
var
ini:TIniFile;
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
  ini:=TIniFile.Create(ExtractFilePath (ParamStr (0))+'setReport.ini');
  Form1.frxReport.Variables.Clear;
  Form1.frxReport.Variables[' ' + 'Seller'] := Null;
  Form1.frxReport.Variables['edit11'] := ini.ReadString('company','edit1','');
  Form1.frxReport.Variables['edit22'] := ini.ReadString('company','edit2','');
end;

Thank you sibprogsistem! This works! However i have two problems:

- in the report the values aren't text but are presented as numbers (also in your example)
- when i run the report for the first time i can see the variables under Seller and use them BUT when i open another report the variables aren't there to use anymore so i can't use them in my report that i am already building

31

(7 replies, posted in Reports)

derek wrote:

Hi Kristof,
Not sure without seeing the actual project, but can you copy the company information that you need to show to calculated fields and then use the calculated fields in the report?
If not, I think you might have to use reportsql rather than report.
Derek.

Hello Derek,

Thanks for your help! yes i was thinking to use calculated fields but i couldn't find out how to get the ini values into the calculated fields.

32

(7 replies, posted in Reports)

sibprogsistem wrote:

.

hello sibprogsistem, thank you so much for example! however my compononents are not on the form where i am executing the report, is there a solution to this?

33

(7 replies, posted in Reports)

Hello friends,


In MVD i write values to an .ini file, like the following example:


company.ini

[company]
Edit1=name
Edit2=address

I need to show this information (company info) on the report, is there any way i can do this?


Thanks in advance

34

(1 replies, posted in Reports)

Hello all,


I solved what i was trying to achieve by using a calculated field in the table and using that on the report.

Hello derek,


Thank you for the help. I managed to fix it, i went into the project file and in the tables.ini file i manually added the field again, this did the trick!

36

(1 replies, posted in Reports)

Hello friends,


Is it possible in report designer to get the INT value of a report field?


For example:


var
   reportfieldint = integer;

begin

reportfieldint:= StrToInt('<Report."reportfield">,MasterData1');

end;

This gives me an error: "is not a valid integer value"

Hello friends,


I accidentally removed a relationship from a table, when i want to add it again MVD says "duplicate column name". Can i fix this?


Thanks in advance!

Hello derek!

Thank you for the help (again)! I had a quick look again and i found the issue myself, i had a report value (StrToInt..., i removed this and now the error is gone and the report shows the value of the newly added field.

Thank you very much for your explanation ehwagner, thank you for the tip on Enigma Virtual Box to hide folders and files, this would have been the second issue i wanted to ask :-)

I'm going to try and test it out!

Hello friends,


I am having a weird problem. My report is working fine, but, as soon as i try to add an extra field from the table to be used as data in the report (in MVD > button > add data > open report in designer) the report breaks and i get an error ".... is not a valid integer" (an error on a field that worked before, and has nothing to do with the field that is added.


Any ideas?


Anyway i am trying to get the value of an id from a table in the report, could i use an SQLExecute in Fast Report?

Something like this in a Label: SQLExecute('SELECT field FROM table WHERE id = ...');

What would be the correct syntax?



Thanks in advance!

Amazing! Thank you for this example and project file sibprogsistem!

42

(7 replies, posted in Script)

amsjunior1 wrote:

It is possible to automatically calculate the total value of column6 of the tablegrid in the textbox

Tablegrid have some filters.

Hello amsjunior1,


try this procedure on event:


begin
    frmMain.Edit1.Value := frmMain.Tablegrid1.columns[5].Footer.Formulavalue; 
end;

43

(4 replies, posted in General)

DriveSoft wrote:

Hello.


Button with action "Save Record" has property  dbGeneralTableId, using this property you can get id of displayed record of form

Form1.Button1.dbGeneralTableId

I didn't know this, thank you for the tip Dmitry! Will come in handy in the future.

44

(4 replies, posted in General)

derek wrote:

Hello Kristof,
I don't believe you can directly display the table ID of a record on a form, so I'd simply use a calculated field instead.
But if you want to perform an sqlexecute statement based on the ID of the record, the ID doesn't actually need to be displayed anywhere - you should be able to retrieve it from the calling form's tablegrid ID  - 
sqlexecute('select fieldname from tablename where id =' +form1.tablegrid1.sqlvalue);
Derek.

Ahhh yess Derek!! Thanks so much again!


sqlexecute('select fieldname from tablename where id =' +form1.tablegrid1.sqlvalue);

Exactly what i needed, works perfect!

45

(4 replies, posted in General)

Hello friends,

Is it possible to show the current id on the form? I tried to add an edit box, referring to table X and field id but nothing shows in the edit box.

I would actually like to perform an SQLexecute based on the ID of the record that is currently shown in the form that is being opened, this way i could hide the text box and use the value.

Thanks

This problem has been solved by Derek (again!), many thanks!

The problem was that i did not have a correct relationship between the two tables.

Hello friends,


I have another problem that i can just not wrap my head around. Ive looked at many examples and searched the forum, the solution might be very simple but i just don't see it.


The problem is that my tablegrid does not show the linked items according to the id of the main table, it just shows all records, not the child records. What is a best practice or recommended way of doing this?


Thanks!

48

(3 replies, posted in General)

derek wrote:

Hi DBK,
I'd try it using a calculated field (see attached).
I've added a (C) or (P) to indicate whether the name in the combobox is Company or Private - this also means that you can easily sort the drop-down list by client type, if required.
Is there a need to have 2 separate fields for 'private name' and 'company name' since you already know from the 'type' which it is? - just a thought.
Hope this helps,
Derek.

Hi Derek!

Thank you so much, again!! This is exactly what i was trying to achieve. Again, very clever using the calculated field! However i couldn't possibly come up with this syntax smile

49

(3 replies, posted in General)

Hello friends,


Here i am again smile sorry


I'm trying to fill a combobox with values from a table called "clients", however, i would like this combobox to show the value of "name" IF the client type is "private" but if the client type is "company" the value listed in the combobox should be "companyname".


I tried to set the combobox properties to {name} {companyname} so they show up both, but it's a bit messy and it would look much nicer if i got it working.


So, in sort of "psuedo code" i am trying something in the lines of the following:


frmAddInfo.ComboBox2.ItemIndex := SQLExecute('SELECT name FROM client WHERE id_client.type = "private'''); 

But obviously this isn't working, i'm at the wrong end again. If someone could help or guide me in the right direction it would be a great help!
Thanks!

Thank you tcoton. I will experiment a bit smile