How to cancel a form close in Close Event?

后端 未结 3 506
情歌与酒
情歌与酒 2020-12-20 15:58

I\'m sure this is very simple, but I can\'t find it. In the close event of an Access Form, how can I cancel closing the form? I have a test that counts the records in a tab

3条回答
  •  臣服心动
    2020-12-20 16:34

    You can use the Unload event:

    GlobalVar ButtonClicked
    
    Private Sub Form_Open(Cancel As Integer)
         ButtonClicked = False
    End Sub
    
    Private ClickMe_Click(Cancel As Integer)
         ButtonClicked = True
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
         If Not ButtonClicked Then
             Cancel = True
         End if
    End Sub  
    

    Order of events for database objects

提交回复
热议问题