Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading & Unloading a form 1

Status
Not open for further replies.

gxdragon

Programmer
Feb 6, 2001
23
0
0
US
I am loading a form when a button is clicked. After that form finishes an upload (or if a cancel button is clicked) it is unloaded. When the form unloads it executes the same line which loaded it in the first place "Load FrmUpload" and I receive an error "run time error 364 - Object was unloaded". Why is it executing the same line twice. I have tried loading and unloading the form in different ways using flags and everything I can think of and it always goes back to the line it left off at, I'm out of ideas. Can someone please help?


Private Sub CmdUpload_Click()
Load FrmUpload
End Sub

Private Sub Form_Load()
Me.Show
DoEvents

'some other code

Unload Me
End Sub
 
Private Sub CmdUpload_Click()
Load FrmUpload
End Sub


I'd suggest that rather than doing all the work in the Form_Load event, you create a public sub that does the work. When you go to load it, do the following:
[tt]
Private Sub cmdUpload_Click()
Load frmUpload
call frmUpload.MyLoadRoutine()
End Sub
[/tt]
That way you've got more control over when your code gets executed.

Chip H.
 
Well, the problem is that u cannot write 'Unload Me' in the Load event of the same form. This is because u are trying to unload the form even before it is actually loaded.

Try unloading so in the Form_Activate event.

-Venkatesh.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top