Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21090

[RESOLVED] how to show a form before exiting the program

$
0
0
i have a mdi form and when i user try to leave then it has a question
i cant figure out how can i ask him 2 questions before he exit the program

1) first if he wants to exit the program then yes no
2) if he says yes the ill ask him if he want to backup the database now
if he says no then the program will close but if he says he wants to back up then the backup form will pop up.
the backup form is named frmBackupDba

this is my code:
Code:

Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  If MsgBox("Are you sure you want to exit?", vbExclamation + vbDefaultButton2 + vbYesNo, "") = vbNo Then
        Cancel = True
        Exit Sub
    End If
 
          CN.Execute "UPDATE Logs SET LogOUT= #" & Format(Now, "HH:MM:SS") & "# WHERE LogID= " & ULog
           
            CN.Close
            Set CN = Nothing
            End
 
End Sub

Gracias

Viewing all articles
Browse latest Browse all 21090

Trending Articles