Solved

UnLoading a form and loading it again!

Posted on 1998-11-30
11
262 Views
Last Modified: 2010-05-03
I am trying to develop a bus scheduling software.
To generate a schedule user has to enter certain number of buses.  But when the user enters buses less than the minimum required, what I am doing is giving an error message and unloading the output form. (Code for generating the schedule is in the Form_load event of the output form).  The  software then takes the user back to the Data entry form.
But when I try clicking the "run the schedule" command button again, it does not go to the Form_load event of the Output form at all.  It just loads the output form with few controls.  So I have to kind of go back and run the schedule again and it works then.

Does anyone have any idea as to why it is doing that?

Any suggestions would be greatly appreciated.

Thanks

Vasant
0
Comment
Question by:vasant
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1447549
Why you are not just validate the input and accept or reject without unloading the form?

You can use a hidden textbox or a variable to have the number in.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1447550
Form load occurs when the form is initially instantiated. This generally happens only once. Form_Activate fires every time the form is given focus.

You can do a UNLOAD to dump the form, but all memory associated with it will be freed and any vars will vanish. Put the code in your main procedure (just block copy out of the Form_Load event). then you can fire it at will with something like:

Formx.hide
call doprocess
Formx.show

M

0
 

Author Comment

by:vasant
ID: 1447551
Well... Mark's suggestion was great...  I actually figured that out.  I did pretty much the same thing.  
Thanks Mark.

Vasant
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 1

Expert Comment

by:rayford
ID: 1447552
Good habits include preloading forms at the start of the program while splash screen is displayed.  This means you dont want much code in the FORM LOAD events.  Instead use Show and Hide to display the desired forms.  To run code when a form is shown you would use the FORM ACTIVATE event and not the FORM LOAD event.  Hope it helps.  This technique is actually going to solve more problems than just the one you currently face.  Happy programming!
0
 
LVL 1

Expert Comment

by:rayford
ID: 1447553
Without seeing the code its not easy to imagine exactly what you are doing but one other thought is you want to use the REFRESH method on things that dont look correct.  Requery, refresh and if your problem has to do with databases linked to controls I often like to use unbound controls for the users to work with rather than having them touching the bound controls directly because it will cause indexed fields to be updated and possible cause you to wind up with unwanted results and side affects..
0
 

Author Comment

by:vasant
ID: 1447554
Thanks Rayford for your suggestion.
This is my first VB Project actually.  I have learned a lot from the mistakes I have made.  I should have written the code in Modules instead of just a big chunk of code.  I guess that would have helped too.

Vasant
0
 
LVL 2

Accepted Solution

by:
Bhargava earned 10 total points
ID: 1447555
Assuming that you are instantiating the values in the form_load event. might be your form is not unloaded or there might be some code after the unload which is referencing the form . So the next time you are accessing the form you are actually showing the form rather than loading it. So the form_load event is not fired. I can give an eaxct solution if I can see the code.
0
 

Author Comment

by:vasant
ID: 1447556
Thanks for your help Bhargava.  I could figure out the problem.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1447557
If you liked my answer so much why did you give the points to Bhargawa? 8-(

M

0
 

Author Comment

by:vasant
ID: 1447558
Well...  I am kind of new to this Expert Exchange thing.  Yours was a comment, right?  So it didn't ask me as to what I want to do with the answer.  It didnt' propose those 4 options (Excellent, good, etc.).   Whereas Bhargava's suggestion was a proposed answer.  Hence I could give points to him.

Tell me how to give points for a comment, I would do that right away.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1447559
Generally what you do is reject the answer and then tell the commenter to repost as a question to award points.

M

0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month4 days, 12 hours left to enroll

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question