I have one view table. Let this be ViewA. This is the master.
I have again a view table that I associate with it. Let this be ViewB. This is the detail.Referential Integrity is not checked. It gives a KEY error when you mark it.I am using Master/Detail Add. I want to assign the master ID value to a field in the detail table. So in ViewB, I want to use the master ID of ViewA. However, I could not get this value. Except for this value, all records are working and I can successfully save master and detail tables.In the Row_Inserting section of the detail table (ViewB), I make the assignments as follows.
$rsnew[“date”] = $GLOBALS[‘viewA’]->date->CurrentValue;However, the following value is empty:
$rsnew[“viewA_ID”] = $GLOBALS[‘viewA’]->id->CurrentValue;I’m looking at the saved tables. There are ID values in my master table. So everything works except this stage.
Is the “id” field of the ViewA (I assume you actually meant TableA) autoincrement? If so, note that in Row_Inserting server event (i.e. before inserting), the master record is not inserted yet, so the id is unknown yet.If the foreign key of the detail table (linked to the master table) is “viewA_ID”, you do not need to update it yourself, the generated scripts should update the field for you.
Yes. The ID field in the master view table is AUTO INC. defined as. But I am trying to read the ID value in the Row_Inserting section of the detail table.Unfortunately, it does not automatically save the ID value to the field in the detail table. But all other data is saved correctly.So is there an alternative solution? For example, which of these tables is saved first? Can I do something in the Row_Inserted section? What I need is to get the ID value of the master table without saving the detail table.
You may post your tables schema (using CREATE TABLE … syntax) for more discussion.