• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 461
  • 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?
0
BrianBeck
Asked:
BrianBeck
  • 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.
0
 
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,
0
 
raja_ind82Commented:
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
 
BrianBeckAuthor Commented:
Dear M. Raja
Thanks - brilliantly simple!

Brian
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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