Switch View during OnLoad - InfoPath Dev
in

InfoPath Dev

Switch View during OnLoad

Last post 09-16-2005 12:55 PM by Patrick Halstead. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 09-14-2005 07:02 AM

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47

    Switch View during OnLoad

    Is this possible. I can't seem to get it working. Here is my code:

    Sub XDocument_OnLoad(eventObj)

    if XDocument.DOM.selectSingleNode("//my:myFields/my:field9").text = "true" then
    XDocument.View.SwitchView("2")
    end if

    End Sub
  • 09-14-2005 07:20 AM In reply to

    Re: Switch View during OnLoad

    Is "2" the name of your view? You do not reference a view by an index if that is what you are trying to do.

    ---Directly from help-------------
    SwitchView Method
    Changes the active view of a Microsoft Office InfoPath 2003 form to a specified view.

    expression.SwitchView(ByVal bstrName As String)
    expression Required. An expression that returns a reference to the View object.

    bstrName Required String. The name of the view to switch to. If an empty string is used, the default view is displayed.

    Security Level
    2: Can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

    Remarks

    If an empty string is used as the bstrName parameter, the view is changed to the default view of the form.


    Example

    In the following example, the SwitchView method of the View object is used to change the current view to the default view:

    XDocument.View.SwitchView("");

    ------------------------
    Jason
    http://www.k2distillery.com/
  • 09-14-2005 07:26 AM In reply to

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47

    Re: Switch View during OnLoad

    2 is the name of the view. I have tried changing it to viewb but it doesn't seem to work either
  • 09-14-2005 07:37 AM In reply to

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47

    Re: Switch View during OnLoad

    i'm not sure i understand this.

    The name of my view is "2".

    so to switch to that view in the onload i can't use the actual name of the view?
    How do i refer to the view then?
  • 09-14-2005 08:34 AM In reply to

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47

    Re: Switch View during OnLoad

    got this cleared up!

    instead of trying to do this with code, I realized i could use rules for the open/save of the document.

    why do i insist of tyring things the hard way first.
  • 09-14-2005 11:07 PM In reply to

    Re: Switch View during OnLoad

    Because you want to learn everything?

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 09-15-2005 07:04 AM In reply to

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47

    Re: Switch View during OnLoad

    But if i learn everything that means more responsibility. HAHAHAHA

    but if this project takes off...means more security for me...good with the bad i guess hahahaha
  • 09-16-2005 12:55 PM In reply to

    Re: Switch View during OnLoad

    If there wasn't good with the bad what fun would life be? :)

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.