Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move Values from Main to Subform

Status
Not open for further replies.

martakeithy

Technical User
Nov 12, 2001
19
GB
Hi,
I am attempting to write some Access Basic code with little progress. I wonder if anyone could advise.
I have a main form and a subform. The first form is called PaymentAmend and contains client bank details and the outstanding balance for the client.
The subform is called PaymentTendered and contains the date and details of each individual payment.
What I want to do is to transfer the value held in the outstanding balance field on the Mainform to the subform. This is to enable a new balance to be calculated when a payment is entered on the subform; i.e to give a figure from which to subtract the payment.
I want the first record: first payment on the subform to grab the value held on the main 'PaymentAmend' form.
I want subsequent records (records 2,3,4 etc...) on the subform to take the amended (new) balance from the previous record - not the outstanding balance from the main form.
I tried to write an if statement which I will paste below. I am working from a book here and am probably missing some vital information.

Private Sub Balance_GotFocus()
Dim Outstanding As Control
Dim CheckSum As Currency
Dim CurrentBal As Currency

Outstanding = Forms!PaymentAmend!Balance
CheckSum = Forms!PaymentAmend!BalancePlace
CurrentBal = Balance

If CurrentBal = 0 And CheckSum = 0 Then
Balance = Outstanding
Else: Balance = CheckSum
End If
End Sub
I would be very grateful of any help
Marta
 
You may be best adding coding to your main form to open a recordset of the records in the subform. Then use code to walk through the recordset and update the balances. After you are done, requery the subform to refresh it on the screen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top