Calculation in main and subforms

beginner_access

Registered User.
Local time
Today, 11:41
Joined
Aug 22, 2011
Messages
21
I have a main form and a sub form.

Subform has a number of fields which is linked to TABLE1

Subform footer has a hidden text field called TXTSUM which sums up the total amount entered in the subform. This is the outbound field where the formula is
Code:
=sum([Approved])

Now in the main form, There is a field called specialty. This is a drop down menu with options like hotel, restaurant, office.

There is another field in the main form called Final_Amount.

Basically, if 'specialty' field is hotel, then Final_Amount should be = TXTSUM * 80

if 'specialty' field is restaurant, then Final_Amount should be = TXTSUM * 120

if 'specialty' field is office, then Final_Amount should be = TXTSUM * 50

I tried this formula under Final_Amount
=IIf ([Specialty] = hotel, TXTSUM * 80, IIf ([Specialty] = restaurant, TXTSUM * 120, TXTSUM*300))


I would like to save Final_Amount in my table as well.

How can I get this to work. Any help or advice will be appreciated. I tried so many ways and some says it won't work as TXTSUM is an outbound field

Thanks in advance
 
Last edited:
Try this code:

=IIf ([Specialty] = forms!YourformName![hotel], forms!YourformName![TXTSUM] * 80, _
IIf (forms!YourformName![Specialty] = forms!YourformName![restaurant], forms!YourformName![TXTSUM] * 120, _
forms!YourformName![TXTSUM]*300))
 

Users who are viewing this thread

Back
Top Bottom