Getting "view is not ready" error - InfoPath Dev
in

InfoPath Dev

Getting "view is not ready" error

Last post 03-09-2006 11:23 AM by Agni Jonnalagadda. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-09-2006 04:23 AM

    Getting "view is not ready" error

    I've got the following code:

    Dim current_view As String = e.XDocument.View.Name
    ' Switch to the accounts version of the print view & print it
    e.XDocument.View.SwitchView("PrintAccountsVersion")
    e.XDocument.PrintOut()
    ' Switch to the originators version of the print view & print it
    e.XDocument.View.SwitchView("PrintOriginatorsVersion")
    e.XDocument.PrintOut()
    ' Now restore the previous view
    e.XDocument.View.SwitchView(current_view)

    On the second SwitchView, I get a "view is not ready" error. If I comment out that line and the second PrintOut call, the error occurs on the attempt to restore the original view.

    I'm wondering if it is because InfoPath is still processing the printing action.

    Any suggestions on what I can do to work around this?

    --Philip
  • 03-09-2006 05:44 AM In reply to

    Re: Getting "view is not ready" error

    You might want to take a quick look at this HowTo:http://www.infopathdev.com/howto/tips/default.aspx?i=9de539adb4e846a5900a2687debb8963

    That error usually happens when you put SwitchView code in the OnLoad event, because InfoPath has not created the views yet.

    Otherwise, what is the "e" object you are using?
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 03-09-2006 06:55 AM In reply to

    Re: Getting "view is not ready" error

    No, it isn't in the OnLoad code, it is in the event handler for a button.

    The idea is that the user click on the button to print the form. My code then checks that there aren't any validation errors, switches to the first print view, prints it, switches to the second print view, prints it and then switches back to the data view.

    --Philip
  • 03-09-2006 07:32 AM In reply to

    Re: Getting "view is not ready" error

    Hmmm ... it looks as if InfoPath doesn't allow/can't cope with sequential view switching:

    http://www.officekb.com/Uwe/Forum.aspx/infopath/643/performing-two-SwitchViews

    Has anyone got any ideas as to how I can implement printing the way I have described?

    --Philip
  • 03-09-2006 11:23 AM In reply to

    Re: Getting "view is not ready" error

    Hi,
    Yes you are right you cannot call switch view in the same method, because view does not view when you call it, it will switch after the execution of the current method. So you can probably call switch view second time in the OnSwitchView() method.

    Other idea is to call switch view method from the taskpnae.
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.