Results 1 to 12 of 12

Thread: unload form

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Porsgrunn,NORWAY
    Posts
    30

    unload form

    one of my forms in my project wont reappear after unloaded the last form.

    'This wont work
    unload game (second)
    startup.show (first)

    'i need to:
    unload startup
    and then
    load startup again!!!
    startup.show

    this will return back to windows GUI and then to startup form.
    Annoying.
    i thought i needed just to unload game, and the startup would reappear. why doesnt it reappear?!
    Last edited by Kennethj; Mar 18th, 2002 at 09:04 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    1. It should be
    VB Code:
    1. Startup.Show
    , not show startup

    2. It sounds like Startup is unloaded when Game is loaded. This means that when Game is unloaded, Startup will have to be implicited loaded again, unless you have the Startup.Show in the unload event of the Game form.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Porsgrunn,NORWAY
    Posts
    30

    damn

    spelling mistake sorry. i have corrected it on my first post. Any who knows why it happens?

    My game has two forms.
    (The first loaded is Startup.frm then game.frm)

    why dont this work:

    unload game
    startup.show
    (project freezes)

    need to do this: (annoying) Switching back to Windows GUI!! then back on to startup.

    unload game
    unload startup
    load startup
    startup.show

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Is there anything in the Game form unload that might conflict with something in the Startup form load?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Porsgrunn,NORWAY
    Posts
    30

    dont think so

    difficult to say, i would have to show you the whole code, but i havent internet at home where my files reside.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Based on what you presented, I can find nothing wrong. Without seeing exactly what these two forms are doing, it is difficult to recommend a course of action. If you could display the Form_Load and Form_Unload of BOTH forms, that might help.

  7. #7
    Member
    Join Date
    Nov 2001
    Location
    Heaven........ Whats that fire doing here?
    Posts
    39

    huh..... I CANT FIND ANYTHING WRONG

    THE FORM WONT LOAD OR IT JUST FREEZES..?

    wouldn't you

    startup.show
    unload game

    ?

    I dont get what you want... ohhhh well...

    Have a nice day!
    []:::::::::::[];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;/

    Did you know that you can be your own grandpa?! It's really cool. . . . . .
    ------------------------------------------------
    But I'm not. . . Im just Myself. . . . .
    Not my own grandpa. . . . . .

    I put on my own pants today. . . . .
    Im so proud of myself. . . . .

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Porsgrunn,NORWAY
    Posts
    30

    hmm

    i havent used form_unload in any projects, and i didnt seem to need them. they worked properly. but maybe i need to do it in this project.

    Give me an example of a code using the form_unload please.

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Unload is typically used for housekeeping chores like closing databases, recordsets etc. and clearing out variables, and closing all forms. Here is a typical Unload event for me.
    VB Code:
    1. Private Sub Form_Unload(Cancel As Integer)
    2.     On Error Resume Next
    3.     Dim i As Long
    4.     'close all sub forms
    5.     For i = Forms.Count - 1 To 1 Step -1
    6.         Unload Forms(i)
    7.     Next
    8.    'close database and recordset objects
    9.    Db.Close
    10.    Set rs = Nothing
    11.    Rs.Close
    12. End Sub

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Porsgrunn,NORWAY
    Posts
    30
    sub forms, do you mean all forms loaded after the first one?

    in my project startup is loaded at first.
    So i use your form_unload code to close all forms, but it will not affect startup.frm. is that correct?

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Porsgrunn,NORWAY
    Posts
    30

    error

    when implementing your unload_form code i receive an error
    Private Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
    Dim i As Long
    'close all sub forms
    For i = Forms.Count - 1 To 1 Step -1
    Unload Forms(i)
    Next
    'close database and recordset objects
    Db.Close
    Set rs = Nothing
    Rs.Close
    End Sub

    The db and rs is not defined.

  12. #12
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Db and Rs won't be defined unless you define them. Those two are created by me to refer to my database object and my recordset object. If you have other variables assigned for these functions, or you are not using a database or recordsets, then you don't need to close them when the form is unloaded.

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