【发布时间】:2014-04-05 15:11:55
【问题描述】:
亲爱的人们,我需要一点帮助。我有一个表单,其中有列表框,通过选择列表框,我在表单中填充了一些字段和子表单。 我想要实现的是子表单不应该有 0 条记录。 所以我有一个控件在哪里检查记录集是否为 0 并弹出一条消息,但退出子没有帮助,用户仍然可以进入下一条记录。
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
【问题讨论】:
-
请向我们展示您的代码。