Consulting

Results 1 to 4 of 4

Thread: UserForm_Terminate

  1. #1

    UserForm_Terminate

    In this code

    [vba]
    Private Sub UserForm_Terminate()
    If MsgBox("Deseja sair sem gravar?", vbYesNo, "Criador de Produtos") = vbNo Then
    form_user_inicial_tecnica.RedoAction
    Else
    Application.Quit
    End If
    End Sub
    [/vba]

    if user chose No it won't show the form again? why?

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    A bit sloppy on my answer, but the Terminate event is happening as the Class/Object is being destroyed. That is, there is no really turning back.

    Thus, I believe one would want to allow a delay, and initialize a new Class/Object. Maybe something like:

    [vba]Option Explicit

    Private Sub CommandButton1_Click()
    Unload Me
    End Sub

    Private Sub UserForm_Terminate()
    Dim uf As MSForms.UserForm

    If MsgBox("Bring back?", vbYesNo, vbNullString) = vbYes Then
    DoEvents
    Application.OnTime Now + TimeValue("00:00:01"), "Reinstate"
    End If
    End Sub[/vba]

  3. #3
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Sorry, 'ReInstate' would be in a Standar Module, like:
    [vba]Option Explicit

    Sub Reinstate()
    UserForm1.Show
    End Sub
    [/vba]

    Hope that helps,

    Mark

  4. #4
    Thanks with your help made like this work

    [VBA]
    Private Sub UserForm_Terminate()
    If MsgBox("Deseja sair
    sem gravar?", vbYesNo, "Criador de Produtos") = vbYes Then
    Application.Quit
    Else
    DoEvents
    Application.OnTime Now +
    TimeValue("00:00:00"), "user_passa_a_seccao.seccao"
    End If
    End Sub
    [/VBA]

Posting Permissions

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