Copy field value into another field in Add page

I want to copy the ID value into the Order_ID field when I’m on the ADD page.
added in Row_Inserted

$val = “” . $rsnew[“ID”];
$sql = “update ordini set ID_Commessa = '”.$val."’ where ID = ".$rsnew[“ID”];
Execute($sql);

does not work.

Your post is not clear enough.

  1. Are the “ID” and “Order_ID” fields in the same table?
  2. Is the “ordini” is the table where the “ID” and “Order_ID” belong?
  3. What is “ID_Commessa” field? What is the relationship between “Order_ID” and “ID_Commessa” field?
  1. Are the “ID” and “Order_ID” fields in the same table?
    you are in the same table.

  2. Is the “ordini” is the table where the “ID” and “Order_ID” belong?
    yes.

  3. What is “ID_Commessa” field? What is the relationship between “Order_ID” and “ID_Commessa” field?
    no relationship.

I would like that when I am in ADD table orders the field ID_Commessa takes the ID code.

Is the “ID” field an auto-increment field type?

Is the “ID” field an auto-increment field type?

YES

Simply put the following code in “Row_Inserted” server event:

Execute("UPDATE ordini SET ID_Commessa = " . $rsnew[“ID”] . " WHERE ID = " . $rsnew[“ID”]);

I entered the code but it doesn’t work.

Please enable the Debug mode to check whether any error message displayed.

004074: (mysqli): SET NAMES ‘utf8’. Error: (0)
0.009075: (mysqli): SELECT * FROM user WHERE (ID = 6) OR (ID IN (SELECT ID FROM user WHERE ID_user = 6)). Error: (0)
0.012966: (mysqli): SELECT * FROM user WHERE ID_user IN (6). Error: (0)
0.041107: (mysqli): SELECT * FROM user WHERE (ID = 6). Error: (0)
0.045270: (mysqli): SELECT * FROM user WHERE (ID = 6). Error: (0)

Please try to insert a new record again, and post the log in here for more discussion.

thanks it works perfectly.