Big Problem #2: Insert/Delete Optional Section Breaks Subtotal

S

Shemp

OK, I have a lot of questions about InfoPath (which I just love BTW),
and I will post them here one at a time so I can track them separately.

The overall setup for each of these questions involves a form I've made
to enter sales orders. It's really fast to fill out and gives us much
greater accuracy in writing up orders. There's a section that has a
Repeating Table to enter products and quantity, which also brings up
the unit price and calculates the extended price. Neat stuff. Then
there are Optional Sections for Discount and Sales Tax, but those don't
apply for most customers.

I have a Repeating Table into which you enter Quantity, pick
Description from a dropdown, and it fills in the Unit Price and
Extended Price. There's also an Optional Section, basically the same
thing except that it lets you enter stuff from outside our standard
product line, like custom projects with special pricing etc. Further
down the form, there's a Subtotal which adds up the Repeating Section
and Optional Section sums, then a Optional Section for Discount and
Sales Tax if applicable, then a Grand Total field.

If you show this Optional Section, then decide you don't want to use
it, when you hide it the Subtotal and Grand Total are NaN. If you show
the Optional Section, even if the value is 0 the totals work but not
when the OS has been shown and then hidden.

I have the values for the fields formatted to Decimal(double) as
Currency, and under Tools/Form Options I've selected "Treat blank
values as zero," so I'm stumped.

One thing I want to be able to do but can't figure out is how to create
a normal If...Then statement, like "If this Optional Section is hidden
return zero, else return what's in the rightmost field." No can do.
How bout you?

If you would like to see a copy of this file, email me at:
J E F F (A T) 5 T R E A |V| B 0 X (d 0 t) C 0 |V|
 
S

Scott L. Heim [MSFT]

Hi Jeff,

I am trying to reproduce the behavior you are describing but I am not
having any luck...let me describe what I have done and let me know if I am
doing anything wrong:

- Created a new, blank form
- Added a Repeating table with 3 columns
- Changed the name of the 3rd column field to: txtRTPrice
- Set this to a "Double" data type and specified "Currency" as the format
with 2 decimal places
- Added an Optional section below this Repeating Table
- Added a new Repeating Table within the Optional Section
- Changed the name of the 3rd column field to: txtO_RTPrice
- Added a text box below the Optional Section and set the Default Value of
this to: sum(txtRTPrice) + sum(txtO_RTPrice) by using the "Insert Formula"
button, clicking the Insert Function button, selecting "Sum" and then
double-clicking where specified to select the appropriate field

I then previewed the form, added some value's to the txtRTPrice field and
the total field updated as expected. I then inserted the Optional Section,
added values to the txtO_RTPrice field and again, the total field updated
as expected. I then selected the option to remove the Optional Section and
the total field reflected the original values - again, as expected.

Am I missing a step or doing something in error?

Thanks Jeff,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Shemp

OK, that totally works on a new blank file. I guess I need to go back
through the logic of my file and see where I went wrong. Thanks!

PS - any tips on where to start looking?
 
S

Scott L. Heim [MSFT]

Hi Jeff,

Unfortunately nothing specific but you may want to make a copy of the
template and then remove any rules, code, etc. and see if it works as
expected. If it does, you would need to add these items back individually
until you find the culprit.

Good luck!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top