Solved

"Unable to unload within this context" error (VB)

Posted on 2007-03-20
4
430 Views
Last Modified: 2013-12-26
Dear Gurus
My VB6 app has a number of child forms.  In almost all, the user clicks Cancel to exit and return to the main form.  However, in a new just-created form, I need the code to automatically unload the form at the end of a process.  When I attempt to do this I receive:
"Unable to unload within this context"
I've tried other's suggestions, eg, activating a 50mS timer.  Placing an 'unload me' in that procedure also returned the same effort.  Even calling a separate routine that unloads the form doesn't help.

Can you help please?
0
Comment
Question by:BrianBeck
  • 3
4 Comments
 

Author Comment

by:BrianBeck
ID: 18761674
i've tried calling a routine in the main form, that invokes a 'child form unload', only to receive the same error.
0
 

Author Comment

by:BrianBeck
ID: 18761701
Note: the last user acrtion is the selection of a drop-down combo box.  From what I've seen, it seems that VB doesn't permit unload routines from combo box event handlers.  But, the event handler calls a separate routine that unloads the form.
Puzzling, and I'm keen to see a solution,
0
 
LVL 14

Accepted Solution

by:
raja_ind82 earned 250 total points
ID: 18762249
In combo box event handlers  you can use "Me.Hide" instead of "unload me" and unload the forms in some other events.

if you want specific code, Please copy your codes here.

Regards,
M.Raja
0
 

Author Comment

by:BrianBeck
ID: 18762305
Dear M. Raja
Thanks - brilliantly simple!

Brian
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now