|
保存基础物料
Private Sub 保存基础物料_Click()
On Error GoTo Err_保存基础物料_Click
Dim i As Integer
Dim STemp As String
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
STemp = "Select * From 物料名称"
Rs.Open STemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If IsNull(Me![物料代码]) = True Then
MsgBox "请输入“物料代码”,它不可以为空!", vbOKOnly, "输入“物料代码”"
Me![物料代码].SetFocus
ElseIf IsNull(Me![物料名称]) = True Then
MsgBox "请输入“物料名称”,它不可以为空!", vbOKOnly, "输入“物料名称”"
Me![物料名称].SetFocus
ElseIf IsNull(Me![规格型号]) = True Then
MsgBox "请输入“规格型号”,它不可以为空!", vbOKOnly, "输入“规格型号”"
Me![规格型号].SetFocus
ElseIf IsNull(Me![计量单位]) = True Then
MsgBox "请输入“计量单位”,它不可以为空!", vbOKOnly, "输入“计量单位”"
Me![计量单位].SetFocus
Else
If Rs.RecordCount > 0 Then
Rs.MoveFirst
For i = 1 To Rs.RecordCount
If Rs("物料代码") = Me![物料代码] Then
MsgBox "该物料代码已经存在,请核实!", vbCritical, "记录已经存在"
Exit Sub
Else
Rs.MoveNext
End If
Next i
End If
End If
STemp = "INSERT INTO 物料名称 "
STemp = STemp & "( 物料代码,物料名称,规格型号,计量单位)"
STemp = STemp & "VALUES ('" & Me![物料代码] & "','" & Me![物料名称] & "',"
STemp = STemp & "'" & Me![规格型号] & "','" & Me![计量单位] & "')"
DoCmd.RunSQL STemp
Me![物料信息].Requery
Set Rs = Nothing
Exit_保存基础物料_Click:
Set Rs = Nothing
Exit Sub
Err_保存基础物料_Click:
MsgBox Err.Description
Resume Exit_保存基础物料_Click
End Sub
当录入字段不完整时,点击_保存基础物料_会出现这个窗口,如何去掉呢?
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|