|
|
Пополнение списка с подтверждением (DAO)
Private Sub Combo_Surname_NotInList(NewData As String, Response As Integer)
Dim rst As DAO.Recordset
Dim str As String
Dim lngRecID As Long
On Error GoTo Combo_Surname_NotInList_Err
str = InputBox("Подтвердите добавление нового значения" & vbCrLf & _
"Фамилия", "Новое Значение Списка!", NewData)
If str <> "" Then
Set rst = CurrentDb.OpenRecordset("Сотрудники", dbOpenDynaset)
With rst
.AddNew
!Фамилия = str
.Update
End With
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
Combo_Surname_NotInList_Bye:
On Error Resume Next
rst.Close
Set rst = Nothing
Exit Sub
Combo_Surname_NotInList_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"in procedure Combo_Surname_NotInList", vbCritical, "Error!"
Resume Combo_Surname_NotInList_Bye
End Sub
Простой вариант:
Private Sub Device_NotInList(NewData As String, Response As Integer)
Dim ctl As Control
With CurrentDb.OpenRecordset("select * from Device")
.AddNew
!Наименование = NewData
.Update
End With
Response = acDataErrAdded
End Sub
|
|