|
再次修改
Private Sub Com单位名称_NotInList(NewData As String, Response As Integer)
On Error GoTo catch
If MsgBox("单位不在列表中,要把这个新单位加进数据库中吗?", vbOKCancel + vbQuestion, "提示") = vbOK Then
DoCmd.RunSQL "INSERT INTO [单位] ([单位名称]) VALUES ('" & NewData & "')"
If Nz(DLookup("[单位ID]", "[单位]", "[单位名称]='" & NewData & "'"), 0) Then
Response = acDataErrAdded
Else
Response = acDataErrContinue
MsgBox "添加新单位没有成功,请重试。", vbCritical, "添加失败"
[Com单位名称].Undo
End If
End If
finally:
Exit Sub
catch:
MsgBox Err.Number & vbNewLine & Err.Description
Resume finally
End Sub
|
|