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 -> PHP

 Stay editing after insert

Print topic Send  topic

Author Message
RussellP

Posts: 20
Posted: 06/29/2007, 10:55 PM

I have a simple update form for adding and editing records. There is a child grid on the same form. The default action for the add button is to add a new record, then bring up a blank record for the next add.

I would like to have an extra button that would 'Add and Stay editing', so that I would commence an update on the record that I have just inserted. The purpose of this is to allow me to commence adding records to the child grid.

Any ideas would be appreciated.

Russell
_________________
Russell P
View profile  Send private message
mamboBROWN


Posts: 1713
Posted: 07/01/2007, 2:52 PM

RussellP
Maybe this example from the example pack can help you: http://examples.codecharge.com/ExamplePack/MasterDetail/MasterDetail.php
View profile  Send private message
Wkempees
Posted: 07/02/2007, 7:27 AM

Reading your post, I deduct the following:
The mentioning of the child grid on the page has no significance for
your question.
So what you actually ask is to have a form with an add button, normal
function and an additional add-and-stay-editing button adding the record
and return to the same form same record in edit mode.
If so, than consider the following:

1:A form will be in insert mode if there is no identifier on the URL.
2:A form will be in edit mode if there is a identifying ID on the URL.

So to create your wish:
Create a New Button on the Form, set it to insert mode, add you ADD and
STAY text, give it a meaningful name "InsertEdit".
In the AfterInsert event add the newly created key (if autonum)to the
URL and redirect to the calling form, depending on button pressed.

If a record is inserted, and the primary key is a autonum key, you will
have to retreive the newly created key as per examples for your database.

  
  	global $DBConnection1; // replace with your own connection, needed to   
be in same SQL session  
  
  	global $Redirect; // contains the return page as passed  
  
// to keep things simple, as I cannot know the name of YOUR button  
  	if ($Component->PressedButton == "Button_Insert"){  
  	// The Normal Insert Button, do nothing  
  	} else {  
  	  $Redirect.="id=" .   
CCDLookup("last_insert_id()","enq_coaches","",$DBConnection1);  
  	}  
  
Working, tested.

Walter
Wkempees
Posted: 07/02/2007, 7:33 AM

AfterInsert event should read AfterExecuteInsert
Vasiliy

Posts: 378
Posted: 07/02/2007, 11:59 AM

Actually after migrating from CCS 3.1 to CCS3.2 I have this functionality as a bug in some of my forms. :-D
_________________
Vasiliy
View profile  Send private message
wkempees


Posts: 1679
Posted: 07/02/2007, 3:23 PM

bug just got promoted to feature.
Are you sure it is exactly as described here?
Report to support ASAP, or thorugh the 3.2 thread.
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Vasiliy

Posts: 378
Posted: 07/02/2007, 9:14 PM

Quote :
Report to support ASAP, or thorugh the 3.2 thread.

Already did, so far no solution.
Don't have time to dig deeper, just rolled back the project.
_________________
Vasiliy
View profile  Send private message
lvalverdeb

Posts: 299
Posted: 10/01/2007, 10:26 AM

The following code, added to the AfterExecuteInsert event, works to switch from add to edit mode (assumes that the pk is called table_id):
  
$last_id = mysql_insert_id(); //or CCDLookUp("last_insert_id()".....   
if ($last_id) {  
	global $Redirect,$FileName;  
	$QueryString = CCGetQueryString("QueryString", array("ccsForm"));  
	$QueryString = (strlen($QueryString)) ? $QueryString.="&table_id=".$last_id:"table_id=".$last_id;  
     	$Redirect = $FileName."?".$QueryString;  
}  

Luis



_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
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.