Switch then Export a View

R

ridawg

Hey,

I'm trying to create a view that can be exported and I've run into some
trouble. Here's the basic idea.

1. User comes in and selects the customer from a dropdown box. Then selects
a button called get data (this queries an Access database).
2. If this is the data the user wants they select Export data - this is
where I'm having trouble. This is what I would like to happen.

a. The view is switched to an "Export" view.
b. The Export view is then exported (using the View.Export) as an MHT file.
c. The view is switched back to the default view.

As far as I can tell you can't use two view statements in a row but there
has to be a way to work around this issue. I don't want to add any buttons to
my Export view. The whole point of this view is to create a document that is
clean and formatted to be shared with our customers.

The weird thing is I can't write two view statments in the same business
logic but I can write one statement (like switch to Export view) then
immediately go to File/Export/Web and everything works fine. What's the
difference between writing two lines of code back to back vs. writing one
line then executing the second statement using the menu system? Both are back
to back.

Any suggestions would be great!
 
G

Greg Collins [InfoPath MVP]

You cannot switch views twice in a row. But you can use the OnContextChange event handler to identify that you are now in your "Export" view and then switch back to the other view. If you reach the Export view from multiple other views, then store somewhere in a secondary data source, the view you are switching form, and then switch back to the stored view.
 
R

ridawg

Greg,

Thanks for the info. How do I use the OnContextChange event in this
situation? I apogolize for my ignorance - I have very little programming
experience. If you could walk me through what your thinking that would be
great.

Thanks!
 
G

Greg Collins [InfoPath MVP]

In the OnContextChange event handler you write some code to see if you are in the Export view... if you are, then you switch views back.

The OnContextChange event won't happen until all your other code (the view switch and export) is done.
 

Ask a Question

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.

Ask a Question

Top