Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / December 2005

Tip: Looking for answers? Try searching our database.

Managed Code equivalent to Refresh Action of a Button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Frumer - 02 Dec 2005 20:12 GMT
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.
Franck Dauché - 02 Dec 2005 21:49 GMT
Hi Mike,

If "Projects" is the name of your secondary data source,
thisXDocument.DataObjects("Projects").Query() should work.  What happens when
you use that code?
Read this post (it is C#, but it is the same issue):
http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=457

Regards,

Franck Dauché

> 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.
Mike Frumer - 02 Dec 2005 21:57 GMT
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?      


> 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.
Mike Frumer - 02 Dec 2005 21:58 GMT
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.

> 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.
Franck Dauché - 02 Dec 2005 22:20 GMT
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

> 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
[quoted text clipped - 8 lines]
> > thisXDocument.View.ForceUpdate() in the OnSwitchView event , but that does
> > not do the same thing.
Mike Frumer - 03 Dec 2005 03:35 GMT
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.

> Sounds to me in your original description that you are calling the .Query()
> code before you call the ForceUpdate in your OnSwitchView.
[quoted text clipped - 16 lines]
> > > thisXDocument.View.ForceUpdate() in the OnSwitchView event , but that does
> > > not do the same thing.
Mike Frumer - 15 Dec 2005 20:58 GMT
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.

> 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
[quoted text clipped - 21 lines]
> > > > thisXDocument.View.ForceUpdate() in the OnSwitchView event , but that does
> > > > not do the same thing.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.