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 / April 2006

Tip: Looking for answers? Try searching our database.

Changing Views and Printing questions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rzwahr@gmail.com - 09 Apr 2006 14:14 GMT
I am trying to accomplish the following things in infopath and have had
problems:  In a nutshell here's what I want to do:

User clicks a "Print Out View A" button I have created and that view
gets displayed as a print preview, they select the printer they want,
print it, and are still on the default view when they are done.  No
switching around (at least manually) between views.

This, at least to me thus far, is WAY easier said than done.  It seems
like this should be very simple though.

The way it seems this should work is, in the code, you could change the
designated print view to Print View A, print the form (using the
PrintOut method), then change the designated print view back to its'
default.  I have several different print views depending on the
audience, so I have to be able to toggle between print views, based on
which view the user wants to print and which button is pressed.  It
seems that this should be easy, and my first attempt was to try and
programmatically switch views, print, then switch back.  I attempted to
use SwitchView to go to Print View A, issue a PrintOut, then SwitchView
back to default view.  As you may guess, that bombed with the "view not
ready" error, which I still don't understand.  Infopath itself switches
views with the click of a button, so why can't I make my form do it???
Anyway, the only way I can get infopath to switch views aside from
clicking the View button and selecting the desired view, is to attach a
switch view rule to a button.  I'd love to know how to do all this in
pure code, but I am a rookie when it comes to this stuff.  The way the
documentation talks about SwitchView, it should just switch your view
if you use it.  This isn't the case, and I can't for the life of me
figure out how to get the view "ready" so I can switch to and from it.

How do I accomplish what I am trying to do - I am positive it can be
done.
Greg Collins [InfoPath MVP] - 11 Apr 2006 00:19 GMT
Note - the problem you are running into is that you CANNOT switch views while I view switch is in progress. This is not allowed.

Since your code is switching views, and then doing other stuff, and then attempting to switch back, this will fail because the first view switch hadn't actually completed yet.

You can however for the view to switch back once it has finished switching the first time by using the OnContextChange event handler. Set some field stating which view to switch back to--in the OnContextChange event handler, check if the field is not blank, and if not, then switch to the view specified in the field.

I'm assuming that the reason you are not using the default, built-in, print view feature is that you want to have more than one print view attached to a single edit view. If this is not the case, just specify the print view for the edit view in the View Properties dialog box.

Signature

Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com

I am trying to accomplish the following things in infopath and have had
problems:  In a nutshell here's what I want to do:

User clicks a "Print Out View A" button I have created and that view
gets displayed as a print preview, they select the printer they want,
print it, and are still on the default view when they are done.  No
switching around (at least manually) between views.

This, at least to me thus far, is WAY easier said than done.  It seems
like this should be very simple though.

The way it seems this should work is, in the code, you could change the
designated print view to Print View A, print the form (using the
PrintOut method), then change the designated print view back to its'
default.  I have several different print views depending on the
audience, so I have to be able to toggle between print views, based on
which view the user wants to print and which button is pressed.  It
seems that this should be easy, and my first attempt was to try and
programmatically switch views, print, then switch back.  I attempted to
use SwitchView to go to Print View A, issue a PrintOut, then SwitchView
back to default view.  As you may guess, that bombed with the "view not
ready" error, which I still don't understand.  Infopath itself switches
views with the click of a button, so why can't I make my form do it???
Anyway, the only way I can get infopath to switch views aside from
clicking the View button and selecting the desired view, is to attach a
switch view rule to a button.  I'd love to know how to do all this in
pure code, but I am a rookie when it comes to this stuff.  The way the
documentation talks about SwitchView, it should just switch your view
if you use it.  This isn't the case, and I can't for the life of me
figure out how to get the view "ready" so I can switch to and from it.

How do I accomplish what I am trying to do - I am positive it can be
done.
 
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.