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の作法 その23

Last updated at Posted at 2022-06-04

概要

access2000の作法、調べてみた。
テーブルにリレーションシップを設定してみた。

写真

image.png

リレーションシップボタンを作る手順。

  • menuフォームを右クリック。
  • デザインビューを開く
  • ボタンを設置
  • ウィザードが開く キャンセル
  • プロパティシートを開く
  • イベントを開く
  • クリック時、コードビルダーを開く

Private Sub コマンド17_Click()
    relation "会派", "議員", "ID", "会派コード", "relation1"
End Sub

Sub relation(T_main As String, T_sub As String, K_main As String, K_sub As String, K_name As String)
    Dim db As DAO.Database
    Dim rel As DAO.relation
    Dim fld As DAO.Field
    Set db = CurrentDb
    Set rel = db.CreateRelation(K_name, T_main, T_sub)
    rel.Attributes = dbRelationDeleteCascade + dbRelationUpdateCascade + dbRelationLeft
    Set fld = rel.CreateField(K_main)
    fld.ForeignName = K_sub
    rel.Fields.Append fld
    db.Relations.Append rel
    Set db = Nothing
    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?