
1.检查数据合法性
2.在要插入的表中检索该记录
3.返回记录条数大于0,提示改记录存在
4.等于0,进行相应处理。
不知道你要解决的是不是这样的问题,希望对你有所帮助。
Text不要和Adodc1绑定,这样:Private Sub Command1_Click()
Adodc1.RecordSource = "select * from 编号 where 编号='" &Text1.Text &"'"
If Adodc1.Recordset.RecordCount >0 Then
MsgBox "记录己存在"
Else
MsgBox "记录不存在"
Adodc1.Recordset.AddNew
Adodc1.Recordset("编号")=Text1.Text
Adodc1.Recordset("其他字段")=Text2.Text
'......
Adodc1.Recordset.Update
End If
End Sub
Private Sub Form_Load()
'这里就不用AddNew了
End Sub
....For i = 0 To Adodc1.Recordset.RecordCount - 1
If Adodc1.Recordset.Fields(" *** 作员").Value &"" <>"" Then
For j = 0 To Combo1.ListCount - 1
If Combo1.List(j) = Adodc1.Recordset.Fields(" *** 作员").Value Then Exit For
Next
If j = Combo1.ListCount Then Combo1.AddItem Adodc1.Recordset.Fields(" *** 作员").Value
End If
Adodc1.Recordset.MoveNext
Next
....
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)