Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form loses data on first use only

Status
Not open for further replies.

ajharn

IS-IT--Management
Jun 8, 2002
71
US
Hi all,

Question for you pros out there. In my Word Application, I have 2 forms used for input. I display them using Form.Show and Form.Hide. I never unload the form until they exit the application.

This is used for a repetitive process. The user does not have to change all the data in the forms each time, so we want to present them with the same data again so they don't have to reenter it.

The process is: do a Form.Show, user inputs data, do a Form.Hide, data is gathered and used by the application (dumped into a template), user finishes the document and then hits the "Next" button, which saves the document, then does a Form.Show again. The Form should be displayed with the data from the last input still populating the fields, because the form was never unloaded, just hidden. And this works smashingly, well...

Except for the very first time they use the form after starting the application. They enter the data the first time and move forward, and when they start the 2nd report, the form is displayed with no data. They enter the data again and move forward, when they start the 3rd report, the form now displays the data and continues do so from that point forward with no further problems.

How come? [shadessad]

Thanks as always,
AJ
 
Hi AJ,

Just thinking out loud before I go to bed ..

First time in you show the form from where - a document_open or an application event or a toolbar or what? After that you show it next time from where - is your Next button on the other Form, or what? Just really wondering whether you somehow have two instances of the form because they are invoked differently - the first one, and all the rest. It might help if you put some debugging displays in the initialise/activate/terminate events.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Hey Tony,

Thanks for the response. I thought I'd be really clever and create a few lines of sample code to replicate the problem, as showing the context of the problem through my actual code is not reasonable here. I've had this problem before in other VBA apps I've written, so I figured it would be EASY to replicate.

Guess what, my sample code works. [3eyes] This is why I don't code for a living.

So, taking your excellent suggestion, I will now be charting the flow of my code and looking for multiple instances or other logic problems and reporting back shortly.

For your immediate reference, the Sub that first shows the 1st form is called from a Toolbar. The command button on the 1st form hides the 1st form and shows the 2nd form. The command button on the 2nd form hides the 2nd form, calls a variety of subs in the module and then lands the user in the resulting document (forms are still hidden, not unloaded). User then hits a "Next Report" button on a toolbar which calls a variety of subs that save documents and then finally shows the 1st form again. Rinse, wash, repeat.

Will get back w/ more info soon. Thanks again.

-AJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top