定数 | コントロール | ||
|
|
|
|
acLabel | ラベル | ||
acTextBox | テキストボックス | ||
acCombBox | コンボボックス | ||
acListBox | リストボックス | ||
acCommandButton | コマンドボタン | ||
acLine | 直線 | ||
acRectangle | 四角形 | ||
acImage | イメージ | ||
acOptionButton | オプションボタン | ||
acOptionGroup | オプショングループ | ||
acCheckBox | チェックボックス | ||
acToggleButton | トグルボタン | ||
acTabCtl | タブコントロール | ||
acSubform | サブフォーム |
■ Access VBA 実行コード
Option Compare Database
Option Explicit
Private Sub コマンド0_Click()
Dim tForm As Form
Dim tCtrl1 As Control
Dim tCtrl2 As Control
Set tForm = CreateForm()
tForm.DefaultView = 0
tForm.Section(0).Height = 2000
tForm.RecordSelectors = False
tForm.NavigationButtons = False
tForm.DividingLines = False
tForm.Caption = "テストフォーム"
'コマンドボタンの配置
Set tCtrl1 = CreateControl(tForm.Name, acCommandButton, , , "", 5000, 1500, 1500, 800)
tCtrl1.Caption = "テスト"
'ラベルの配置
Set tCtrl2 = CreateControl(tForm.Name, acLabel, , , "", 200, 200, 2500, 800)
tCtrl2.Caption = "動的にコントロールを作成し配置"
DoCmd.OpenForm tForm.Name
DoCmd.Restore
DoCmd.MoveSize Right:=1000, Down:=500, Width:=8000, Height:=3500
MsgBox "閉じます"
DoCmd.Close , , acSaveNo
Set tCtrl1 = Nothing
Set tForm = Nothing
End Sub