TopPicLogo TopPicText

Добавление поля в таблицу

Private Sub AddNewField()
Dim fld As DAO.Field
Dim tbl As DAO.TableDef
Dim db As DAO.Database

On Error GoTo AddNewFieldErr
    Set db = CurrentDb
    Set tbl = db.TableDefs("tblExample")
    Set fld = tbl.CreateField("exNewFieldINT")
    'Определение свойств поля
    With fld
        .Type = dbInteger
        .DefaultValue = 0
    End With
    'Добавление
    tbl.Fields.Append fld

AddNewFieldBye:
    Exit Sub

AddNewFieldErr:
    MsgBox "Error " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
    "in procedure AddNewField of Module mod00Test", vbCritical, "Error!"
    Resume AddNewFieldBye
End Sub



Назад ToTop
L.E. 16.11.2012
Рейтинг@Mail.ru