Solved

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

Posted on 2007-03-20
4
433 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

863 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

19 Experts available now in Live!

Get 1:1 Help Now