CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 How do I stop Insert from custom code events

Print topic Send  topic

Author Message
jim7567g

Posts: 38
Posted: 02/05/2005, 8:15 AM

Hello, I have the following custom code set in the "Before Insert" section.

  
//Custom Code @175-9470612E  
// -------------------------  
    global $production_hours1;  
    $userlog = CCGetFromPost("user_login", "");  
    $gettimestamp = CCGetFromPost("week_time_stamp", "");  
    $timestamp = strtotime($gettimestamp);  
	$year = date('Y', $timestamp);  
    $weeknum = date('W', $timestamp);  
	$together = $userlog . $weeknum . $year;  
    $production_hours1->unique_id->SetValue($together);  
    global $DBvestora_production;  
    global $check;  
    $result = CCDLookUp("unique_id", "production_hours", "unique_id='". $together . "'", $DBvestora_production);  
    $result = strval($result);  
    $check = $result;  
	    if ($check == $together)  
    {  
        $production_hours1->unique_id->Errors->addError("Duplicate Entry");  
    }  
  
// -------------------------  
//End Custom Code  

I am concerned about the last few lines of this code where I am performing a unique entry check. The check is working correctly and I am getting the error message returned to the browser that there is a duplicate entry but I have not been able to figure out how stop the insert.

Should I be using this code in another events section?
_________________
Jim
View profile  Send private message
peterr


Posts: 5971
Posted: 02/05/2005, 11:31 AM

Your code should work in the OnValidate event. Also take a look at the InsertAllowed property in the docs. There is an example of how to prevent record insert.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
jim7567g

Posts: 38
Posted: 02/05/2005, 2:31 PM

Thanks Peter, the InsertAllowed property did the trick.
_________________
Jim
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.

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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