7,763
社区成员
发帖
与我相关
我的任务
分享
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If Me.ActiveForm Is Nothing Then Exit Sub
gblnClose = False
Dim tempControl As Object
For Each tempControl In Forms
If tempControl.Caption <> "主界面" Then
Unload tempControl
If gblnClose = True Then Exit Sub
End If
Next
For Each tempControl In Forms
If tempControl.Caption = "主界面" Then
tempControl.Caption = ""
Unload tempControl
End If
Next
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Me.Caption = "主界面" Then
MsgBox "主界面不能关闭!", vbInformation, "提示"
Cancel = 1
End If
End Sub
销售单在关闭时有如下代码:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim inti As Integer
If tlbToolBar.Buttons("ADD").Value = tbrPressed Or tlbToolBar.Buttons("EDIT").Value = tbrPressed Then
inti = MsgBox("数据尚未保存,是否直接退出?", vbYesNoCancel + vbQuestion, "提示")
End If
Select Case inti
Case 6
Call tlbToolBar_ButtonClick(tlbToolBar.Buttons("SAVE"))
Case 7
Unload Me
Case 2
Cancel = 1
gblnClose = True
End Select
End Sub