This topic is locked
[SOLVED]

 Auto increment field ADD detail records

12/29/2014 9:07:18 AM
PHPRunner General questions
G
GregJ author

PHPR 8, mySQL.
Unable to ADD child records (on Master Add page) when Master table has an auto incremented key field linking it to the detail tables. The key field shows up blank on the Add page. No problem using Edit page to add details after the Master record has been created. Is there a way to 'pre-fetch' the value of the master key field from the table into the form so that child records can be added at the same time on the same Add page?
This seems like pretty basic stuff but I could find only one old post http://www.asprunner...for-new-record/ which says it's not possible.

Sergey Kornilov admin 12/29/2014

Link two tables as Master-Details and choose 'Display child records on Add page' option. This option can be found in master-details relationship properties.

G
GregJ author 12/29/2014



Link two tables as Master-Details and choose 'Display child records on Add page' option. This option can be found in master-details relationship properties.


Yes, I have done that, no problem.
I can't add records to the child tables on that Add page though because there is not yet any value in the Master key field. The auto incremented master key appears in the master table record only when the new record is added to the table[size="2"]. Since we haven't yet added the record there is no key so the details can't relate to the master on the Add page.[/size]
I'm thinking that a dummy record added to the Master table through the custom add event might work but that seems a bit clunky when there may be a much more elegant solution.

Sergey Kornilov admin 12/29/2014

If you follow my advise both master record and details records will be added at the same time and master key value will propagate to details table.

G
GregJ author 12/29/2014



If you follow my advise both master record and details records will be added at the same time and master key value will propagate to details table.


Don't know what I'm doing wrong then. Here's a visual.
First, adding the new record:


Save, then edit the same record.


I thought it had something to do with the master key but maybe I'm missing something simple?

Sergey Kornilov admin 12/29/2014

Yes, it's very simple - remove Ordernum and order# fields from details tables Add/Inline Add pages.

G
GregJ author 12/29/2014



Yes, it's very simple - remove Ordernum and order# fields from details tables Add/Inline Add pages.


No luck getting it to work in my 'real' app. I deleted the add field settings like you said, saved & rebuilt. Removed the master / detail relations altogether and recreated. Reset all the screens. Saved and exited PHPR and restarted. No cigar. Finally I set up a sandbox app with a master and two detail tables which works like a charm!
Thanks for pointing me in the right direction Sergey. I'll figure it out later and update you here when I have found it.

G
GregJ author 12/30/2014

I finally got this to work. I had to connect to my project tables through PHPmyadmin and purge them. They didn't look like they had corrupt data in them but something in there was preventing the detail tables from updating. Hope this doesn't re-occur when I have live data in them!