Managed Code equivalent to Refresh Action of a Button

M

Mike Frumer

What is the vb.Net managed code equivalent of having a button with the
"Refresh" action to refresh a secondary data source?

I have tried thisXDocument.DataObjects("Projects").Query() and
thisXDocument.View.ForceUpdate() in the OnSwitchView event , but that does
not do the same thing.
 
M

Mike Frumer

I am using managed code to allow a user to add values to a dropdown list.

I have a repeating table which includes a dropdown list and some text boxes.
It also icludes a button to allow the user to add an entry to the dropdown
list. The data source for the dropdown list is an Access table.

When the user clicks the button, the form switches to a view which contains
a text box in which the user enters the new value for the dropdown. The user
then clicks a button. My vb.NET code adds the new value to the Access
database table and switches the view back to the repeating table. The managed
code uses thisXDocument.DataObjects("Projects").Query() and
thisXDocument.View.ForceUpdate() in the OnSwitchView event to repopulate the
dropdown.

The new entry is shown as the selcted value in the dropdown, and it also
appears in the list for the dropdown. This is exactly what I want to happen.

HOWEVER, when the user adds a row to the table and drops the dropdown list
down, the new value is not in the list. The value is still in the dropdown
for the first row, and it is in the Access table.

I tried using the thisXDocument.DataObjects("Projects").Query() and
thisXDocument.View.ForceUpdate() in the OnContextChange event because that
event fires when the row is added to the table. That did not help.

Strangely, when I traced the OnContextChang event, the
thisXDocument.DataObjects("Projects").Query() executed, but when I stepped
the code, it did not go to the next line, which is the
thisXDocument.View.ForceUpdate(). It apparently just exits the subroutine.

I am new to InfoPath and managed code, and it has taken me a lot of effort
to get this far. I would greatly appreciate help with this last step.
Was this post helpful to you?
 
M

Mike Frumer

I found that if I put a button with a Refresh action on the main view and
click it after I return to that view, the new list item appears in the
dropdowns for all repititions - as it should. That was why I was asking how I
could do that programmatically. It looks like I must have my "Query" in the
wrong event or something.
 
F

Franck Dauché

Sounds to me in your original description that you are calling the .Query()
code before you call the ForceUpdate in your OnSwitchView.

Try to call the .Query() refresh after you called the ForceUpdate (in the
same event handler).

Franck
 
M

Mike Frumer

Thanks. I will try that - although all of the examples I saw in InfoPath
Developer blogs do the ForceUpdate after the Query, and doing it that way
works for the dialog box in the row that is current when the user adds an
item. It just doesn't work for subsequent repititions.
 
M

Mike Frumer

This problem turned out to be an apparent bug in the IDE.
When I published the InfoPath form to SharePoint and used the form, the
Query worked as it is supposed to.
 

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