Hi Derek

I tried the simple option 1,  checked line per line, double checked...compared your code with mine on Microsoft word to make sure they were identical (except for the reference to the databases columns). And still can't get it to work.

I even thought it could be the date format, so I added a date dd/mm/yyyy field from my initial date field that is  yyyy/MM/dd. And still nothing.

At least I don't get an error message.

Any theories to help me out ?

Thank you Derek

That is exactly what I was looking for. The basic version is perfect.

Now comes the fun part—I need to take some time to go through it piece by piece, understand what you did, and see how all the parts connect together. From what I can tell already, there's a real elegance in its clean simplicity.

Looks like I have a great weekend project ahead of me. Thanks again!

Here you are..sorry.

Here you are...Note that the amount I put in for the grid is just random. I didnt count each accurately from my table.

Here is a mock of what I want to do, very simple. Note my creative EXCEL image for what I want the report to look like. I also would like to either print on excel or FAST REPORT.

tks

I will attempt to make a small mock of the tables and forms.  Please do not pay attention to my script put up earlier. Its what the internet suggested and I wasn't going anywhere with it, simply because it was deep in code and I couldnt make heads or tails of it.

Be right back !

Hi everybody

I am attempting to do an SQL SEARCH such that I have a list of dates indicating the closure of client files. The quary is to see how many files have been closed during week periods. So that you could see that on any given weeks the quantity closed.

FROM                TO                        QTY
2026-01-01         2026-01-07           32
2026-01-08         2026-01-14           12


Best I could manage with the little program and help from the net was the below, but i keep getting blocked :

table : reference
column : Datecompletion
grid :  reports.Gridperformance       (and the property i think is sqlvalue)

Any help would be amazing cause im starting to loose my mind.

Tks.



reports.GridPerformance.sqlValue := SQLExecute(
    'SELECT ' +
    '    date(DateCompletion, ''-'' || ((strftime(''%w'', DateCompletion)+6) % 7) || '' days'') AS week_monday, ' +
    '    COUNT(*) AS total_in_week ' +
    'FROM referalDb ' +
    'GROUP BY week_monday ' +
    'ORDER BY week_monday;'
);

8

(6 replies, posted in General)

Hi Derek

Ive taken the time to study both options and extrapulated some of the ideas, but my problem is that I need to transfer from one table to another.
I've made a little demo of what I am looking for but faced with some sql ISSUES.

I also think there is a question of ID from my customer table that comes into effect, but I dont have enough knowledge or forsite know if that applies.

Here is a small demo of where I am at, and the issue I am getting, before I can continue puzzling out my next steps.

9

(6 replies, posted in General)

Thanks Derek
Thats good.

Side question. Is it possible or fisable to have the checkbox data transfered to another Grid table. I would assume there would be SQL programming necessary ?

At the end, i need to do some searchs which i feel is more sold with grids then with a memo box.

10

(6 replies, posted in General)

Hi all

I want to add checkbox in a table grid and found multiple references on how to do it, but none explain how they create the #Checkbox and #Auto-Number.

I've been on this for a while but can't make sense of it..

I linked an image showing what I want, which are in the table grid.
TKS.

11

(1 replies, posted in SQL queries)

Hi Everybody

I'm attempting to generate a report from a GRID which will automatically (by opening the form willclick a button, starting the sql)  list all clients that are passed 30 days.

Here is what i managed to develop, but it still doesn't work.

     SELECT     Sipad,Namecombined,date30days   
     From          ClientDbf         
     WHERE     DATE(date30days) > DATE(('now', '-30 days');   


Any tips ?

Also I did manage to attempt something that didn't work, and ended up getting the date columb in the grid with hours 00:00:00  is there something in the SQL script i must do to truncate it to only the date ?

Tks.

jeff

12

(1 replies, posted in SQL queries)

Hi Everybody

I'm a beginner in scripting and attempted to find the answer in the form but might not have had the vocabulary to getting about finding what I wanted.

I am working with a waiting list for clients such that I need to update the whole database of how many days people have been waiting.

An initial date has been entered when a request was made, but unless I enter in each file manually and save the database will not update how many days the client is waiting.

I am use this script when I enter the form (Onshow) and when I click the Save button to update the table.

VAR
    // Calculate number of days client on waiting list.
    i : integer;
    iDays: integer;
    start, stop: integer;

Begin    // Calculate the number of days client is on waiting list.
    if ClientCreate.DateAssigned.Checked = false  then
         begin
            iDays := 0;
            start := Trunc (ClientCreate.DateDiscipline.date);
            stop := Trunc (date);
                 for i := start to stop do
                         Inc(iDays);
                Begin
                      ClientCreate.ClientDaysWaiting.Value := iDays;         
                end;
         end;


I would like to have a script that upon entering the main menu, the table for all the clients is updated automatically.

Any help would be greatly appreicated.

Tks.
Jeff

13

(4 replies, posted in SQL queries)

I finally got it working.

After trying to UPDATE without success, I started second-guessing myself and thought it was INSERT.

Sparrow brought me back on track, and I noticed after some research that my MAIN mistake was a set of DOUBLE QUOTES that I was missing.


Here is the coding for anybody interested. Watch out for those single and double quotes

    SQLExecute('UPDATE dtClientName SET NACommunication1= " '+fmNeedsAssessment.NACommunicationText1.Text+' " WHERE id='+fmClientSearh.TableGrid1.sqlValue);       


Thanks all.

14

(4 replies, posted in SQL queries)

Thanks tcoton

I know it was something silly....

It unblocked that issue but I'm getting a new error.

Would have an idea what it is this time?

    SQLExecute('INSERT INTO dtClientName(NACommunication1) VALUES ("'+fmNeedsAssessment.NACommunicationText1.Text+'") WHERE id='+fmClientSearh.TableGrid1.sqlValue);

15

(4 replies, posted in SQL queries)

Hi everybody.

Can anybody see the error in my logic?

I get an error but the error seems to be what I want.

dtClientName = Table
NACommunication1 = Field in Table

The command is triggered by a Button - Onclick
------------------------------------------------------------
    SQLExecute('INSERT INTO dtClientName(NACommunication1) VALUE ("'+fmNeedsAssessment.NACommunicationText1.Text+'")WHERE id='+fmClientSearh.TableGrid1.sqlValue);

-----------------------------------------------------------
any help would be greatly appreciated.

16

(2 replies, posted in SQL queries)

Hi

This is a similar question that I had but with a twist (I previously could use a GRID to get an SQL reference but now I am using a different Table and only have a combobox as a point of connection)

I want to force an answer into a combobox from a different table. It works with a Textbox, but not with Combobox

The reason behind my crazy, is that I can get the users to use the search button with the combobox (otherwise I wouldn't know how to get around this problem)..

Here are 2 lines of code similar in function but information placed in 2 different formats (TEXTBOX and COMBOBOX) I just get a blank in combobox..

*** From a selection of a condobox = cdClientResource,  you will look up the table dbManager of ManagerNameCombined and place it in Combobox

Push to a text box (ClientManagerText)

# 1

fmClient.ClientManagerText.text:=SQLExecute('Select ResManagerText FROM dbResource WHERE id= '+fmclient.cbClientResource.sqlvalue);

Push to a combo box (cbClientManager.)

# 2
fmclient.cbClientManager.text:=SQLExecute('Select ResManagerText FROM dbResource WHERE id= '+fmclient.cbClientResource.sqlvalue);


see ATTACHED PDF. I find it hard to explain my problem.

17

(3 replies, posted in SQL queries)

Hi Derek

And thanks as it works.

This example of coding directly within a Database tables, using a field, brings a new dimension in attempting to manipulate data.

I still don't know how whole script line works but I have a concrete example to dissect and think about.

With my little knowledge of programming, your example was scripted SQL  ?


Also, do you recommend any books for both Delphi and SQL that would coincide with MVD ?

18

(3 replies, posted in SQL queries)

Hi all

If there is anybody that help me solve this issue. 
I've gotten his far in my search with my minimal on going learning of SQL.

I want to filter everybody over a certain age.
Originally I was scripting everybody's AGE and saving in the table. I then realized that it wouldn't get updated automatically and would have to go into everybody's account and press save.

So I know the answer lies in SQL and came up with some kind of logic !
I know it doesn't work but Im missing the gaps of programming to get it going.


At Form startup (SQL QUERY)

        SELECT client, message, FROM dbclient
        WHERE
                date(Datebirth) – curdate() >= 58;


Result is sent to a table.

19

(6 replies, posted in Script)

On the same Theme

Is it possible to not refer to a grid but tell the combobox of the value you want.(Knowing that the value exists in the selection field).

Here is an example but I tried it but didnt work.


procedure fmGroupPresence_OnShow (Sender: TObject; Action: string);

     Begin
          fmGroupPresence.ProgressType.dbitemid:='For closure';
     end;

20

(6 replies, posted in Script)

Ohhh my god..   So simple and elegant.  Once again I was over thinking this problem.
Programming is an ART.

Thank you Derek this will bring what I am doing to a higher level, with such simplify.

21

(6 replies, posted in Script)

Hi Derek

The idea is correct, but it wouldn't be the id but the name.
I was under the impression that giving the ID to the combo box would; give me text assigned to the TEXT

So when I open a form, based on a previous grid, the Name of the selected grid would appear in the combobox.



.

22

(6 replies, posted in Script)

Does this make any sense ?

      fform.combobox1.dbSQLExecute('SELECT id FROM dbClientName WHERE id='+fmClientsSearch.TableGrid1.sqlValue);   


I'd like to basically force an answer into a combo box, as I am limited in my programming skills, this would be a quick loop around  my problem.

(p.s. what is in the fmclientSearch.TableGrid would be the same list that would be available in the combo box)


Help and thanks to anyone.

Thanks Sparrow

I was over thinking this and I got into a mind jam.

     tmpID :=SQLExecute('SELECT id FROM dtClientName WHERE id=' +fmClientSearh.TableGrid1.sqlvalue);

I'll be working on the second part later on today.

much appreciated

Jeff

Hi Everybody

I am trying to extract the ID number (For example : of a client) by using SQL, convert that Number into a string.

I then will use that Number(id) to "INSERT INTO database (Client, Update, price) values ('id','On Hold', 'Price pending');

So my question has 2 parts.


1) Extracting the id using sql using Delphi scripting:   
     
Example ( I can do this which extracts the info but not the ID) 
fmGroupPresence.GroupProgressClientName.Text:= SQLExecute('SELECT txClientName FROM dtClientName WHERE id='+fmClientSearh.TableGrid1.sqlValue);


2) How to insert a string into an sql using sql. I will be using the SQL BUTTON , which all is done in mysql..


Example (as a test ive forced info into the table by doing this, but would need the client number to be scripted.)

insert into dtFollowing(id_dtClientName,ProgressEdited,txtTitle,txNote)  values ('23','Yes','Test','Testnote');         

Sorry Im not more clear as I don't have the lingo used to explain what i need to do.


Thanks for your help.



Jeff

Thanks, Derek, that was it.

So now I am going in the schema and looking at the linked tables and slowly scripting a cascading delete of each table before the last delete, which is the central database of clients.

I appreciate the help all give on the forum. Thanks.