0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

access2000の作法 その6

Posted at

概要

access2000の作法、調べてみた。
CreateTableDef使ってみた。

テーブルを作る手順。

  • menuフォームを右クリック。
  • デザインビューを開く
  • ボタンを設置
  • ウィザードが開く キャンセル
  • プロパティシートを開く
  • イベントを開く
  • クリック時、コードビルダーを開く
Private Sub コマンド9_Click()
    Dim db As Database:
    Set db = CurrentDb
    Dim Tbl As TableDef:
    Set Tbl = db.CreateTableDef("事業所")
    Dim flds As Fields
    Dim fld As Field
    Dim prp As Property
    Dim i As Long
    Dim idx As Index
    'db.Execute ("DROP TABLE 事業所;")
    With Tbl
        Set fld = .CreateField("ID", dbLong)
        fld.Attributes = dbAutoIncrField
        .Fields.Append Object:=fld
        .Fields.Append .CreateField("所在地", dbText, 255)
        .Fields.Append .CreateField("事業所名", dbText, 100)
        .Fields.Append .CreateField("郵便番号", dbText, 10)
        .Fields.Append .CreateField("取扱局", dbText, 80)
        .Fields.Append .CreateField("修正コード", dbText, 8)
    End With
    With Tbl
        Set idx = .CreateIndex("PrimaryKey")
        idx.Fields.Append idx.CreateField("ID")
        idx.Primary = True
        idx.CreateProperty "ID", dbLong
        .Indexes.Append idx
    End With
    db.TableDefs.Append Tbl
    MsgBox "ok"
End Sub
  • フォームを閉じる
  • 保存する

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?