1

(8 replies, posted in SQL queries)

DriveSoft wrote:

meideprac-x
Check out this example:

procedure Form1_bScript_OnClick (Sender: string; var Cancel: boolean);
begin
    Form1.GridEmployees.dbSQL:='SELECT id, "$autoinc", lastname, firstname, salary FROM employees'; // the id field, want to be able to edit or delete the entry from the table component
    Form1.GridEmployees.dbGeneralTable := 'employees'; // Optional (in the case of complex SQL queries with sub queries, you need to choose the main table of the database, also it need to be able to edit or delete the entry from the table component)
    Form1.GridEmployees.dbListFieldsNames :='delete_col,#,name2,name3,name4'; // If you do not want to see the value of the id in the component table, enter a name for the column delete_col
    Form1.GridEmployees.dbSQLExecute;
end;

Thanks Dimitry, "$autoinc" is the solution. It's what I was looking for big_smile

2

(8 replies, posted in SQL queries)

DriveSoft wrote:

meideprac-x
Can you more explain, what exactly you want to do?

Hi Dimitry!
I have a table with an ID column that has no correlative number (because I deleted rows above) and I want to present it in a tableGrid whose field ID must have correlative number. That is so easy with the Object Inspector > properties > settings > select #Auto Increment like explain Mathias, but I use this tablegrid to display different data according to different search criteria I and dump the data using script (principal.TableGrid.sbSQL := 'SELECT id, name, phone  FROM database'), without using the Object Inspector.
How could I add a column in this tablegrid wich was Auto Increase within script?
I hope I explained well, excuse my bad English
Thanks!
Javi

3

(8 replies, posted in SQL queries)

mathmathou wrote:

But if you are talking about rowid as in "number of the row in the tablegrid", even if you have deleted records, there is a way to display a column in your tablegrid with continuous numbering.


In the set-up of your tablegrid (or search button) just had the "# (Auto Increment)" found at the very bottom of the field selection window and you'll get a colum displaying a continuous numbering. If you put it side by side with the "record id" and you have deleted some records, you'll see the difference.


Hope this helps.


Cheers


Mathias

Hi Mathias! Thanks. That's I want to do, but with a script. Could you help me please?

4

(8 replies, posted in SQL queries)

tcoton wrote:

principal.TableGrid.sbSQL := 'SELECT id, name, phone  FROM database';   //should do the trick

Thanks but id shows the id of the record. if I deleted records before use the statemen the number shown is not correlative , and I'm looking for a autoincrement column only shown in the tablegrid.

5

(8 replies, posted in SQL queries)

Hi!

How could I show de row id in a tablegrid load from a database with    principal.TableGrid.dbSQL  ???

                      principal.TableGrid.sbSQL := 'SELECT rowid, name, phone  FROM database';        >>>>> doesn't work sad

Thanks !!!

6

(6 replies, posted in Reports)

Thanks Dimitry for your help!!! That works fine now

7

(6 replies, posted in Reports)

DriveSoft wrote:

meideprac-x
Please attach your project, I'll try to help you.

Hi Dimitry!

- It should be very simple but I can not resolve a syntax error when I save a record within script (than you can see it works perfectly within an action "save record").

- How could I pass var "words" to the report SQL without using a table ??

- In the script you wrote to pass numbers to words, it would be possible that when the cents were 0, it dont write "zero cents" ??

Thanks!

Javi

8

(4 replies, posted in General)

jean.brezhonek wrote:

Hello meideprac-x



Can this help you ?

const
  APP_NAME = 'My App Name';

procedure Form1_OnShow (Sender: string; Action: string);
begin
  Form1.Caption := '';
  if FindWindow(nil, APP_NAME) <> 0 then
  begin
      ShowMessage('Application is already launched.');
      Form1.Close;
  end;
  Form1.Caption := APP_NAME;
end;


begin

end.

JB

Thanks JB !!!  That works fine wink

9

(4 replies, posted in General)

Hi Dimitry!
Is there any way to detect if, when the application opens, there is already an open session of the same application? (To avoid accidentally open twice in the same client).
Thanks!
Javi

10

(6 replies, posted in Reports)

DriveSoft wrote:

Hello,


Can you more explain about your question?

Hi Dimitry!!!
I'm using the function Real2CheckAmount that you explain in other topic, to wirte numbers in Catalan language (Spain), and all works fine. The problem is that I get a result like this "dos-cents cinquanta-nou euros i vint-i-cinc cèntims"., stored in a variable just before activate the report SQL. And I don't know how could I print that in my report (a sort of payment receipt), as I have tried to store it in a column of a table but do not get it (a syntax error I know not resolve).
I thought maybe I could send it to the report through a variable, but some instruction I've found, in MVD is not supported (like global object       frVariables['Reporting Period'] := 'January';         ).
I hope I explained now, excuse for my English.
Thanks.
Regards!
Javi

11

(6 replies, posted in Reports)

Hi,
Anyone know how could I pass the value of a variable to a report without using a table or a view ??
( something like frVariables[ ] )
Thanks!
Javi

12

(6 replies, posted in Reports)

DriveSoft wrote:

meideprac-x
Another example for you

Thanks Dimitri, but I need that the report prints label form left to right  and up to bottom; and your project prints labels from up to bottom and left to right.

Thanks anyway. I will use my first method, adding empty records to my table at the begin. It seems more easy.
Regards!!!

13

(6 replies, posted in Reports)

DriveSoft wrote:

Hello,


I made some changes in your project, now you can enter range for printing records.

Hi Dimitri!

thanks for the project, but is not what I wanted. Sorry, I do not explain so well in English.

Imagine, I have a piece of paper where I can print 24 labels, and the report start printing from left to right and top to bottom. Now imagine that I've already used once that sheet to print five labels, then I can print now only 19 labels. If I want to use this leaf I have to start printing on the label number six, as the first five are not. How can I do it?

14

(6 replies, posted in Reports)

DriveSoft wrote:

Hello,


Can you attach your project for example?

Hi!
Its a simple project with a report to print labels.
The question is that sometimes I have some sheets of labels with tags worn at the beginning, and I want to start printing from an accurate label.
I hope to explain well; my English is not good, sorry.
Thanks!

15

(6 replies, posted in Reports)

Hi guys!
I have a report to print labels in 3 columns and 8 rows and it works fine, but I would like to begin printing in a certain specific position.
One option could be to add as many records as blank labels have the sheet. Someone can help me with any other idea please?
Thanks!

16

(4 replies, posted in SQL queries)

mathmathou wrote:
SELECT
     datetime(asset.date_added) AS 'Original Date',
     datetime(asset.date_added,'+65 year') AS 'Modified Date'
FROM
     asset
WHERE
     asset.id = 13

Thanks Mathias, that works fine!! big_smile

17

(4 replies, posted in SQL queries)

Hi,
How can I add 65 years to a date field in a SQLExecute ?? I've tried adddate but retuns "No such function". Any idea please?
Thanks in advance!
Javi

18

(2 replies, posted in Reports)

prahousefamily wrote:

Please Attach Your Project In Web board  For Help.

Hi prahousefamily!
Thank you. I've already got. The data in the tablegrip came from a VIEW and therefore not carried the report. Now I dump them into a table before, and then I pass them to report, and it works.
Regards!

19

(2 replies, posted in Reports)

Hi!
I have selected a Tablegrid as a component involved for the search, and I have selected de database and the fields, but when I print the report, all the records of my database are printed instead only the records showed in the tablegrid.
What I'm doing wrong?? It's there any other way to do it??
Thanks!!!

20

(2 replies, posted in SQL queries)

DriveSoft wrote:

Hello,


Please check out this solution
http://stackoverflow.com/questions/3845 … -user-name

Thanks Dimitri! I'll try it.

21

(2 replies, posted in SQL queries)

Hi!
I'm trying to replace a field  of a table with the value of a field in another table, and I'm writed that:

SQLExecute('UPDATE tableA, tableB SET field_tableA = field_tableB WHERE field_tableA = tableB.id');


tableA                 tableB
field_tableA       tableB.id
                             field_tableB

... and it returns "Error message: near "," : syntax error" ....

could any one help me please??

Thanks!!!

22

(2 replies, posted in General)

ehwagner wrote:

procedure Form1_Edit1_OnKeyDown (Sender: string; var Key: Word; Shift, Alt, Ctrl: boolean);
begin
    If Key = 13 then Form1.Button1.Click;    // The Button1 action is set to Show Form2
end;

However, you do not need to simulate the button click unless you have a reason to.,  You can just call the form  - see below
   If Key =13 then Form2.Show;

Thanks ehwagner!!! That works ok!!

Hi!
Do any of you know how to do that after entering a value in a cell and press ENTER that calls a form.button.click?
Thanks!!

Hi!
Do any of you know a way to hide or show objects on a form depending on the outcome of a combobox in the same form??
Thanks!

25

(6 replies, posted in General)

ehwagner wrote:

Using Jean's example you can do the following to reset the ID field in the EMPLOYEES table:
SqlExecute('Delete from sqlite_sequence where name=''Employees''');

Thanks ehwagner!! Works OK