D
Debs
I'm new to InfoPath...I have a button labelled"Previous". When the button is
pressed, I would like for it to go to the previous view.
pressed, I would like for it to go to the previous view.
S.Y.M. Wong-A-Ton said:Let's say you have two views with the names: "View 1" and "Final". On "View
1" you have a button with a rule set on it to go to view "Final" whenever the
button is clicked. On view "Final" you have your "Previous" button.
Add a field to your Main DOM via the "Data Source" pane. Let's call it
"lastViewName". Go to view "View 1" and add another rule to the button that
says:
Set a field's value: lastViewName = "View 1"
Now go to view "Final" and double-click on the "Previous" button to open its
"Properties" dialog box. Click on the "Edit Form Code..." button to add an
OnClick event handler for the button. Microsoft Script Editor will open and
the cursor will be located in the OnClick event handler for the button. Add
the following code where the cursor is located:
var lastViewName = XDocument.DOM.selectSingleNode("//my:lastViewName").text;
XDocument.View.SwitchView(lastViewName);
Note: I'm assuming that you're using JScript to program. Before you click on
the "Edit Form Code..." button on the "Properties" dialog box of the button
on the view you must make sure that your language is set correctly by
checking this via Tools > Options... > Design tab > Default programming
language.
Save your work and test it.
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.