First, I'm just a starter and now writing a visual force page and apex
Basically, I have objects A and B, A is master and B is detail, every time creating a B I will set the default balance value as the same as A, my code is as below:
//visual force page:
<apex:inputField value="{!acc.A__c}"/>
//apex code:
public void upgrade(){
A__c bc;
bc.Id = acc.A__c;
Decimal str = bc.Balance__c;
acc.Balance__c = str;
insert acc;
}
it didn't work for some reasons, so is there any way to get the value of the master A_c and copy it into the same field B_c??
any helps are welcomed!!!