i have 6 forms and a mdiform... below are the code i want to close the forms...
'Close in File menu
Public Sub mnuClose_Click()
Unload Form1
End Sub
Public Sub UnloadAllForm()
Unload Form1
Unload Form2
Unload Form3
Unload Form4
Unload Form5
Unload Form6
End Sub
'Sub in Form1
Public Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim Style As VbMsgBoxStyle
Dim Response As VbMsgBoxResult
If FileHasChanged = True Then
Style = vbYesNoCancel + vbQuestion
Response = MsgBox("Do you want to save this file1?", Style)
If Response = vbYes Then
Cancel = True
MDIForm1.mnuSaveAs_Click
ElseIf Response = vbNo Then
UnloadAllForm
FileHasChanged = False
ElseIf Response = vbCancel Then
Cancel = True
End If
Else
UnloadAllForm
End If
End Sub
'Sub in other 5 forms
Public Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Unload Form1
End Sub
am i missing any??
coz .. when i close the form(not Form1)...by clicking the cross at the window corner...
1.) a msgbox will pop up.. but when i press cancel.. the form will invisible
2.) if select yes... once i press cancel from the save dialog.... the form will invisible too...
it work fine when i close the form from the FileMenu, or by clicking the cross at form1...
plz...
'Close in File menu
Public Sub mnuClose_Click()
Unload Form1
End Sub
Public Sub UnloadAllForm()
Unload Form1
Unload Form2
Unload Form3
Unload Form4
Unload Form5
Unload Form6
End Sub
'Sub in Form1
Public Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim Style As VbMsgBoxStyle
Dim Response As VbMsgBoxResult
If FileHasChanged = True Then
Style = vbYesNoCancel + vbQuestion
Response = MsgBox("Do you want to save this file1?", Style)
If Response = vbYes Then
Cancel = True
MDIForm1.mnuSaveAs_Click
ElseIf Response = vbNo Then
UnloadAllForm
FileHasChanged = False
ElseIf Response = vbCancel Then
Cancel = True
End If
Else
UnloadAllForm
End If
End Sub
'Sub in other 5 forms
Public Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Unload Form1
End Sub
am i missing any??
coz .. when i close the form(not Form1)...by clicking the cross at the window corner...
1.) a msgbox will pop up.. but when i press cancel.. the form will invisible
2.) if select yes... once i press cancel from the save dialog.... the form will invisible too...
it work fine when i close the form from the FileMenu, or by clicking the cross at form1...
plz...