• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 468
  • Last Modified:

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

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?
  • 3
1 Solution
BrianBeckAuthor Commented:
i've tried calling a routine in the main form, that invokes a 'child form unload', only to receive the same error.
BrianBeckAuthor Commented:
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,
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.

BrianBeckAuthor Commented:
Dear M. Raja
Thanks - brilliantly simple!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now