Sub test1()
    Dim DB As DAO.Database
    Dim TD As DAO.TableDef
    
    Set DB = CurrentDb
    Set TD = DB.CreateTableDef("tbl商品")
    
    TD.Fields.Append TD.CreateField("商品名", dbText, 20)
    TD.Fields.Append TD.CreateField("在庫数", dbLong)
    
    DB.TableDefs.Append TD
    
    Set TD = Nothing: Set DB = Nothing
    
End Sub

--------------------------------------------------------
 
Sub test2()
    Dim DB As DAO.Database
    Dim TD As DAO.TableDef
    Dim FD As DAO.Field
    
    Set DB = CurrentDb
    Set TD = DB.CreateTableDef("tbl商品")
    
    Set FD = TD.CreateField("商品名", dbText, 20)
    TD.Fields.Append FD
    
    Set FD = TD.CreateField("在庫数", dbLong)
    TD.Fields.Append FD
    
    DB.TableDefs.Append TD
    
    Set TD = Nothing: Set DB = Nothing
    
End Sub

--------------------------------------------------------

Sub test3()
    Dim DB As DAO.Database
    Dim TD As DAO.TableDef
    Dim FD As DAO.Field
    
    Set DB = CurrentDb
    Set TD = DB.CreateTableDef("tbl商品")
    
    Set FD = TD.CreateField
    FD.Name = "商品名"
    FD.Type = dbText
    FD.Size = 20
    TD.Fields.Append FD
    
    Set FD = TD.CreateField
    FD.Name = "在庫数"
    FD.Type = dbLong
    TD.Fields.Append FD
    
    DB.TableDefs.Append TD
    
    Set TD = Nothing: Set DB = Nothing
    
End Sub


FD.Type  dbText, dbLong, dbDouble, dbBoolean, dbDate


 ↓ facebook のフォローで応援してください。お願いします。



Microsoft Office ブログランキングへ