+ Start a Discussion
SFDC DummySFDC Dummy 

page error in vf

Visualforce Error
Help for this Page

System.NullPointerException: Argument cannot be null.
Error is in expression '{!displaingTable}' in component <apex:commandButton> in page todaystesting: Class.dateInPBTbaleController.calculateTotalRevenue: line 32, column 1
Class.dateInPBTbaleController.displaingTable: line 25, column 1

Class.dateInPBTbaleController.calculateTotalRevenue: line 32, column 1
Class.dateInPBTbaleController.displaingTable: line 25, column 1

 
public with sharing class dateInPBTbaleController {
    public BankBook_Entry__c account{get;set;}
    public List<BankBook_Entry__c> listAccount {get;set;}
   
    public Date startDate1;
    public Date endDat1;
    public Double totalRevenue {get;set;}
    public Double totalRevenue1 {get;set;}
     public Double totalRevenuee {get;set;}
     public Date dat {get;set;}
    public dateInPBTbaleController() {
       
        account = new BankBook_Entry__c();
         totalRevenue = 0;
        totalRevenue1 = 0;
        totalRevenuee = 0;
      
    }
     public void displaingTable(){
        startDate1 = account.Date__c; 
        endDat1 = account.Date__c;
        listAccount  = [SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c
                          FROM BankBook_Entry__c
                        WHERE Date__c>=:startDate1 AND Date__c<=:endDat1 ];//Date__c>=:startDate1 AND
        calculateTotalRevenue();
        calculateTotalRevenue1();
       
     }
     public void calculateTotalRevenue() {
        for(BankBook_Entry__c acct : listAccount) {
            if(acct.Debit__c!= null)
                totalRevenue += acct.Debit__c+acct.Bank_Closing_Balance__c;
                //totalRevenuee = totalRevenue  
              
        }
        
    }
    public void calculateTotalRevenue1() {
        for(BankBook_Entry__c acct1 : listAccount) {
            if(acct1.CB__c!= null)
                totalRevenue1 += acct1.CB__c;
               
        }
        
    }
}

 
Chandra Sekhar CH N VChandra Sekhar CH N V
Can you debug your 'listAccount' and see if the query is returning any rows?
ClintLeeClintLee
This error "Class.dateInPBTbaleController.calculateTotalRevenue: line 32, column 1"  would indicate that Line 32 is the problem.  

On Line 32, you have two fields that you're trying to add:  acct.Debit__c + acct.Bank_Closing_Balance__c.  

Since you're doing a null check on the Debit__c field it's most likely that you have an Account with a NULL Bank_Closing_Balance__c field.

You could also perform a null check on the Bank_Closing_Balance__c.

Line 31 would look like this.
if(acct.Debit__c != null && acct.Bank_Closing_Balance__c != null)