CodeCharge Studio All ASP PHP Perl ColdFusion Java C#.NET VB.NET

Examine Form's Mode

This example shows how to identify if a record form is in Add or Edit mode. Edit mode occurs when a record has been retrieved and can be altered or deleted. Add mode occurs when no record has been retrieved in which case the only possible operation would be to add a new record.

  1. Add the Before Show Event.
  2. Within the event, add the code below:

ASP

Function Form1_BeforeShow(Sender)

  If (EventCaller.EditMode) Then
      'Edit Mode
  Else
      'Add Mode
  End If

End Function

PHP

function Form1_BeforeShow(& $sender) {
global $Form1;

  If ($Form1->EditMode) 
     // Edit Mode
  Else 
     // Add Mode

}

Perl

sub Form1_BeforeShow() {

  if ($Form1->{EditMode} == 1) {
    #Edit Mode
  } else {
    #Add Mode
  }
  
}

ColdFusion

<--Form1_BeforeShow -->
  <CFIF blnEditModeForm1>
    <!--- Edit mode --->
  <CFELSE>   
    <!--- Add mode --->
  </CFIF>

VB.Net

'Form1_BeforeShow

  If (IsInsertMode) Then
    'Add Mode
  Else
    'Edit Mode
  End If

C#

//Form1_BeforeShow

  if (IsInsertMode) {
    //Add Mode
  } else {
    //Edit Mode
  }

Java

//Form1_BeforeShow

   if (e.getRecord().isEditMode()) {
    //Edit Mode
  } else {
    //Add Mode
  }
 

See Also:

Before Show Event


On-line, printable versions and updates