Unusal xOptional::remove behavior (on my view)

D

duncans

I have the following simple select case in my code (VB.NET managed code) to
remove an optional section if the user selection from a dropdownlist box
changes:

'Remove any existing optional sections.
Select Case e.OldValue
Case "2"

Case "7"

Case "12"

'Mileage
thisXDocument.View.SelectNode
(thisXDocument.DOM.selectSingleNode("/my:myFields/my:ExpenseReport/my:ExpenseReportDetail/my:MileageExpense"),
System.Reflection.Missing.Value, System.Reflection.Missing.Value)
thisXDocument.View.ExecuteAction("xOptional::remove",
"group3_3")
End Select

The code removes the desired optiona section BUT when the last statement is
excuted, instead of dropping out of the select case loop, the entire loop
tries to execute again and throws an error. If I click through the error the
optional section has indeed been removed. Does anyone have any insight as to
why this might be happening? Thanks.
 
J

Jerry Thomas [MSFT]

If this is on the "OnAfterChange" event, it is because we have to go through
twice.
The first time we go though, we change the the value to blank and then we
come through again and change it to the value you selected or entered.

Try something like this:
function msoxd_my_field2::OnAfterChange(eventObj)

{

if (eventObj.IsUndoRedo || eventObj.Operation != "Insert")

{

return;

}



//do whatever you want here...

}


--
Jerry Thomas[MSFT]
<[email protected]>
Microsoft Office InfoPath
---------------------------------------
This posting is provided "As Is" with no warranties, and confers no rights.
Use of any included script sample are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
Please do not send email directly to this alias. This alias is for
newsgroup purposes only.
 

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