Topic: Error in my logic

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.

Post's attachments

Attachment icon Capture.JPG 16.1 kb, 83 downloads since 2022-10-27 

Re: Error in my logic

How about VALUES instead of VALUE?

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

VALUES is a key word, it does not get singular if you insert only one value wink

3 (edited by jeffmtl@hotmail.com 2022-10-26 23:52:59)

Re: Error in my logic

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);

Post's attachments

Attachment icon Capture.JPG 16.74 kb, 84 downloads since 2022-10-27 

4 (edited by sparrow 2022-10-27 07:58:56)

Re: Error in my logic

INSERT command does not have a WHERE clause because it inserts a completely new record.

INSERT INTO table (name) VALUES('Hello');

It's not entirely clear what you want to do?
Assign ID manually? In the future, this can lead to conflicts if the ID matches.
I don't think your database is set up correctly.

Re: Error in my logic

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.