Results 1 to 6 of 6

Thread: Object was unloaded error

  1. #1

    Thread Starter
    Fanatic Member mikeycorn's Avatar
    Join Date
    Jun 2000
    Location
    Aliso Viejo, CA, USA
    Posts
    526

    Object was unloaded error

    Code:
    Private Sub cmdLoadChapters_Click()
      Load frmChapters
      frmSplash.Hide
      Unload Me
    End Sub
    
    In the frmChapters Form_Load
    
      Me.cdbPath.ShowOpen
      FullPath = Me.cdbPath.filename
      If Len(Dir(FullPath)) = 0 Or Len(FullPath) = 0 Then Unload Me: Exit Sub
    When I cancel out of the cdb on the second form, (triggering the Unload Me in the last line) how come I get an 'Object was Unloaded' error from the first line of the first form that loaded it?
    ~ mikeycorn

    With over 45,000 Questions in the User Submitted Database, it's the Most Popular Quiz Creation Software on the Net:

    PEST - The Personal Exam Self-Tester

  2. #2
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    specify the form name you want to unload rather than unload me

    I think after you open the other form, the Unload Me statement actually unloads that form, not the form you want

  3. #3

    Thread Starter
    Fanatic Member mikeycorn's Avatar
    Join Date
    Jun 2000
    Location
    Aliso Viejo, CA, USA
    Posts
    526
    Nope, I tried it, still the same error.
    ~ mikeycorn

    With over 45,000 Questions in the User Submitted Database, it's the Most Popular Quiz Creation Software on the Net:

    PEST - The Personal Exam Self-Tester

  4. #4
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    Ok, try unloading the form in Form_Activate instead

    So do something like this

    VB Code:
    1. 'In frmChapters
    2.  
    3. Private blnExit as Boolean
    4.  
    5. Private Sub Form_Load()
    6.     blnExit = False
    7.  
    8.     cdbPath.ShowOpen
    9.     FullPath = Me.cdbPath.FileName
    10.  
    11.     If Len(Dir(FullPath)) = 0 Or Len(FullPath) = 0 Then
    12.         'Exit this form!!!
    13.         blnExit = True
    14.     End If
    15. End Sub
    16.  
    17. Private Sub Form_Activate()
    18.     If blnExit = True Then
    19.         Unload Me
    20.     End If
    21. End Sub
    22.  
    23. Private Sub Form_Unload(Cancel As Integer)
    24.     Set frmChapters = Nothing
    25. End Sub
    26.  
    27. '**************************************************
    28.  
    29. 'In frmSplash
    30.  
    31. Private Sub cmdLoadChapters_Click()
    32.     Unload frmSplash
    33.     frmChapters.Show
    34. End Sub
    35.  
    36. Private Sub Form_Unload(Cancel As Integer)
    37.     Set frmSplash = Nothing
    38. End Sub

  5. #5

    Thread Starter
    Fanatic Member mikeycorn's Avatar
    Join Date
    Jun 2000
    Location
    Aliso Viejo, CA, USA
    Posts
    526
    Well, I just got sidetracked into something else so I won't be able to try it out and tell you if it works for a little bit, but I did want to thank you for your help . . .

    I bookmarked the thread and shall return.
    ~ mikeycorn

    With over 45,000 Questions in the User Submitted Database, it's the Most Popular Quiz Creation Software on the Net:

    PEST - The Personal Exam Self-Tester

  6. #6
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    It does work i tried it myself :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width