|
7#
楼主 |
发表于 2006-4-9 23:39:00
|
只看该作者
Private Sub Command16_Click()
On Error GoTo err_Command16
Dim stemp As String
Dim rs As ADODB.Recordset
Dim i As Integer
Set rs = New ADODB.Recordset
stemp = "select * from DNC"
rs.Open stemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If IsNull(Me.DNC) = True Or IsNull(Me.oper_no) = True Then
MsgBox "没有添加DNC", vbOKOnly, "警告"
Me![DNC].SetFocus
Else
rs.MoveFirst
For i = 1 To rs.RecordCount
If Me.item_no = rs("item_no") And Me.rtg_no = rs("rtg_no") And Me.oper_no = rs("oper_no") Then
MsgBox "不能重复加入", vbOKOnly, "警告"
Me.oper_no.SetFocus
Else
rs.AddNew
rs("item_no") = Me.item_no
rs("item_desc_1") = Me.item_desc
rs("rtg_no") = Me.rtg_no
rs("oper_no") = Me.oper_no
rs("dnc") = Me.DNC
rs("memo") = Me.memo
rs.Update
MsgBox "添加完成!", vbOKOnly, "添加完成"
End If
rs.MoveNext
Next i
End If
exit_Command16_click:
Exit Sub
err_Command16:
MsgBox Err.Description
Resume exit_Command16_click
End Sub
|
|