Private Sub COLOR_BeforeUpdate(Cancel As Integer)
Dim STRSQL As String
Dim RS1 As Recordset
STRSQL = "SELECT * FROM SPEC list WHERE SPEC list.SPECNAME='" & Me.SPECNAME & "'AND SPEC list.COLOR='" & Me.COLOR & "'"
Set RS1 = CurrentDb.OpenRecordset(STRSQL)
If RS1.RecordCount <> 0 Then
MsgBox "你输入的资材已经有记录,请重新输入!"
Exit Sub
End If
End Sub[em18][em18][em18][em18][em18]作者: AlexLiu 时间: 2002-11-7 16:48
对于这种情况,建议用DLOOKUP,还有当表名中有空格时,表名要用“[]”说明。
Private Sub COLOR_BeforeUpdate(Cancel As Integer)
Dim STRSQL As String
STRSQL = "SPECNAME='" & Me.SPECNAME & "'AND COLOR='" & Me.COLOR & "'"
If not isnull(DLOOKUP("SPECNAME","[SPEC list]",STRSQL) THEN
MsgBox "你输入的资材已经有记录,请重新输入!"
cancel=true
Exit Sub
End If