Results 1 to 8 of 8

Thread: Unloading Forms in VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    4

    Angry

    Can anyone give me help with unloading forms. I have an application that has two forms open. One of the forms shows mapping and the other is a query form. Basically what I am doing is using the query form to select features from the map. Everything is working fine except for the fact that after I unload my query form I go to my map form and do some work on the map. All the code runs through but there is a delay with VB and it goes into the code to unload the form but the form doesn't actually fully unload until it is finished the work on the map form. This is really annoying as my query form is still visible when it shouldn't be.

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    How about hiding it. Forms can still process commands while hidden.
    Iain, thats with an i by the way!

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    Unload

    unload one form or all forms


    'create a bas module
    '
    Public Sub UnloadAllForms()
    Dim Form As Form
    For Each Form In Forms
    Unload Form
    Set Form = Nothing
    Next Form
    End Sub

    '
    '==================================================
    'place this in your exit event
    '
    Call UnloadAllForms
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    4
    Hiding the form does the same thing. My query form starts to unload and the map form becomes active. Basically my application hangs for a few seconds while it goes through the work on the map form. I know that my map form is coming in too fast, I did try and pause the program after the unload but that didn't work.

  5. #5
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    How about. It might work if i understand wht you are getting at.

    Code:
    Me.Hide
    
    Unload Me
    Iain, thats with an i by the way!

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    4
    I'll try to explain a bit more. I start with a form (frmMain) that has an Active X control for mapping. I have different types of data in this map one of which is Excavation sites. I want to query my Excavations on their name so I click on the Query button and bring up my form (frmExcavQBF). When I click on my 'Query' button on this form it goes out to a module and performs an SQL query on a database. At the end of this procedure I unload my frmExcavQBF. A procedure is then called to write the ID numbers of the excavations into a VB Collection and then on frmMain these excavations are redrawn in a different colour. The problem occurs at the stage when frmExcavQBF gets unloaded. Before I unload the two forms are open with frmExcavQBF being the active form. When I unload frmMain becomes active but frmExcavQBF doesn't unload properly until the application finishes building the VB Collection and redrawing the excavations. To me it looks like the application is racing through and doesn't have enough time to release frmExcavQBF before it moves on to the next piece of code.

  7. #7
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Here i go again.

    Assuming the Procedure to write to the collection is called from frmExcavQBF.

    Before this hide the form. You may have to put a DoEvents in as well. Then unload where you usually do.


    Other wise, unload the form, and before you build the collection use DoEvents.

    Hope this rectifies things.
    Iain, thats with an i by the way!

  8. #8

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    4
    Excellent, that worked perfectly. Thanks a million for your help

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