各位高手:
小弟是一名初学者,在试做添加记录,要求添加的编号不能与已经输入的编号重复,小弟搞了半天弄不出来,希望各位高手给予赐教,小弟不胜感激。
记录号在gzb的表单中是主索引。
我的代码:
Adodc1.RecordSource = "select*from gzb where 编号='" & Text1.Text & "'"
If Adodc1.Recordset("编号") = Text1.Text Then
MsgBox "编号存在"
Adodc1.Refresh
Else
Adodc1.Recordset.Update
End If
刚一运行Adodc1.RecordSource = "select*from gzb where 编号='" & Text1.Text & "'"就报错。请大家不惜赐教。
小弟是一名初学者,在试做添加记录,要求添加的编号不能与已经输入的编号重复,小弟搞了半天弄不出来,希望各位高手给予赐教,小弟不胜感激。
记录号在gzb的表单中是主索引。
我的代码:
Adodc1.RecordSource = "select*from gzb where 编号='" & Text1.Text & "'"
If Adodc1.Recordset("编号") = Text1.Text Then
MsgBox "编号存在"
Adodc1.Refresh
Else
Adodc1.Recordset.Update
End If
刚一运行Adodc1.RecordSource = "select*from gzb where 编号='" & Text1.Text & "'"就报错。请大家不惜赐教。
或
Adodc1.RecordSource = "select * from gzb where 编号=" & Val(Text1.Text)
Adodc1.RecordSource = "select * from gzb where 编号='" & Text1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "编号存在"
ElseIf Adodc1.Recordset.RecordCount = 0 Then
'执行写数据表记录
End If