Results 1 to 8 of 8

Thread: Disabling "X" on the form and re-enabling it later.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Posts
    31

    Post

    Is it possible to disable the "X" on the form whenever processing is being done by the form and then re-enable it when the processing is complete. *We process data against DB2, and it takes couple of seconds (sometimes 10-15) before the operation is complete. And we don't want the user to fool around and click on "X" when the data update is taking place"

    TIA.

  2. #2
    Lively Member
    Join Date
    Nov 1999
    Posts
    98

    Post

    take a look at my response here:

    http://www.vb-world.net/ubb/Forum1/HTML/011482.html

    it answers your question perfectly.

    --michael

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Posts
    31

    Post

    michael,

    thanks for the code. that piece of code works fine for removing "X". But the re-enabling of "X" does not work properly even though I am calling it with MF_INSERT option.

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Try this instead. This would be in your form's QueryUnload Event.
    Code:
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    
        If UnloadMode = vbFormControlMenu Then
            ' g_bProcessFinished is a (perhaps) global variable
            ' that you would set to true when your long-running
            ' process is complete.
            If Not g_bProcessFinished Then
                Beep
                MsgBox "Please wait. Process is not finished"
                Cancel = True
            End If
        End If
        
    End Sub

    ------------------
    Marty

  5. #5
    Guest

    Post

    Just a thought "outside-of-the-box".
    In SQL, would transactions help you?
    (Begin Transaction, Rollback Transaction, and Commit Transaction)
    You may not have to worry so much about the X in the window.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Posts
    31

    Post

    transaction will help when data is being inserted/updated or deleted. but what do you do when data is being selected ?

  7. #7
    Guest

    Post

    I don't know your specific application's needs, but if my user doesn't want to wait for normal processing (fooling around with the X), then he/she probably doesn't want to commit the transaction either. Your original post said , "update", but anything within the transaction is taken as a group or the group is not taken with a Rollback.
    If it really is just a select, then why do you care about the X ?
    Begin Transaction
    Select * From MyTable
    Commit Transaction (if window is still alive, else rollback)
    ...is valid anyway.

  8. #8
    Lively Member
    Join Date
    Nov 1999
    Posts
    98

    Post

    ghost...i don't know if you saw this (i missed mit my first time trying to run this piece of code) but you have to use the InsertMenu function instead of the RemoveMenu function WITH the MF_INSERT parameter in order to re-insert the "X" into your program. it should work fine then. any other problems try e-mailing me with specifics and i will see what's going on...

    hope this helps. happy programming!!

    --michael
    [email protected]

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