@Shiva. Thank you so much for your idea. Its working great. But small change is needed for my requirement. I need the opening balance for each record.So I just created inter groups(i.e. first grouped the records by its name and inside,it was grouped by its serial no.,so that i can get values for each record)
Then as you said but without using the counter part.
In the footer section(grouped by Serial No), create a formula field:
Shared Numbervar a;
a:=//the value you want to pass
In the header section(grouped by Serial No),create a formula field:
Shared NumberVar b;
Shared NumberVar a;
b:=a;
Finally,In the details section formula field,
Shared Numbervar b;
b