Private Sub lstRev_BeforeUpdate(Cancel As Integer)
Dim DataConn10 As New ADODB.Recordset
Dim Comm10 As String
Set Conn = CurrentProject.Connection
Comm10 = " SELECT tblLIVE.SID " & _
" FROM tblLIVE " & _
" WHERE tblLIVE.CID = " & Me.txtCID & " And tblLIVE.PID =
" & Me.txtPIDRev & " And tblLIVE.MNumber = '" & Me.txtSMNum & "'"
DataConn10.Open Comm10, Conn, adOpenKeyset, adLockOptimistic
If DataConn10.RecordCount = 0 And Not IsNull(Me.txtMIDRev) Then
Dim x As Integer
x = MsgBox("Are sure that you want to leave the form without adding Line in subform. If you press yes Rev will be deleted. If you press No please enter Line", vbYesNo)
If x = vbYes Then
MsgBox "Delete"
Else
MsgBox "EnterSOV"
'Here I need something to tell him to stay in the same record :(
DataConn10.Close
Exit Sub
End If
End If
End Sub
答案 0 :(得分:0)
您可以添加Cancel=True
以防止更新前方法完成。只需在Exit Sub
之前添加此内容。