CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Automating Entering Foreign Key in Editable Grid

Print topic Send  topic

Author Message
JayEdgar


Posts: 77
Posted: 02/23/2012, 7:47 AM

I'm amazed I haven't faced this before.

On a current project I have a number of instances where a form needs a subform (child records) for additional information. I'm not actually using subforms on the same page, but opening a new page in a new tab or jQuery dialog box.

When Child records are added, they need the foreign key (FK) to the parent record's primary key (PK) added to be associated to the parent record (obviously). If I update the Child's FK automatically this causes problems, as the user may not need to add 3 (or even 1) new records!

Currently I'm putting a "Fill" button next to the FK field on the child form. How have you handled the same situation? I'm thinking that before save I can update the FK field with the value, and I'm not sure of the best way to do that.

Thanks in advance,

Jay
View profile  Send private message
cvboucher

Posts: 191
Posted: 02/23/2012, 10:37 AM

What I've done in the past is to set the Custom Inert Type to Table. Then for the parameter I want to populate I set the "If parameter is empty: Use value" to Request.QueryString("s_SomeSearchField") of a search parameter (VB.NET). You will need at least one field in the editable grid that gets populated by the user so CodeCharge knows it is inserting that record.

I've also used this to populate current date/times into new records and it will also work for hidden fields if you don't want to give the user the option of selecting the parent record in a drop list.

HTH,
Craig
View profile  Send private message
JayEdgar


Posts: 77
Posted: 02/23/2012, 10:59 AM

Craig, that's brilliant! I'm so glad I posted in here--I wasn't very hopeful.

Thanks so much!

Jay
View profile  Send private message
JayEdgar


Posts: 77
Posted: 02/27/2012, 2:14 PM

I added something else to Craig's suggestion. The foreign key for this table is passed via query string ($_GET). I added code to the Form_BeforeShow code that if the get string is empty, set $Form->EmptyRows = 0. This way, they can't even add new data if the parameter isn't sent.

Craig, thanks again for this elegant solution!

Jay
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.