回答編集履歴
2
誤字の修正
test
CHANGED
@@ -26,9 +26,9 @@
|
|
26
26
|
|
27
27
|
Public Sub SetFuncFormOnLoad2()
|
28
28
|
|
29
|
-
Const FrmLst = "AA注文在庫,BB注文在庫,CC注文在庫" '対
|
29
|
+
Const FrmLst = "AA注文在庫,BB注文在庫,CC注文在庫" '対象フォームのリスト
|
30
30
|
|
31
|
-
Const txtLst = "メモ,工場用メモ" '対
|
31
|
+
Const txtLst = "メモ,工場用メモ" '対象テキストボックスのリスト
|
32
32
|
|
33
33
|
Dim Frm
|
34
34
|
|
1
投稿先を間違えた内容なので編集
test
CHANGED
@@ -1,17 +1,61 @@
|
|
1
|
-
|
1
|
+
上の回答の関数の改良版
|
2
2
|
|
3
|
-
|
3
|
+
テキストボックスのイベントプロパティに直接、関数を設定。
|
4
4
|
|
5
|
-
=FormOnLoad()
|
6
|
-
|
7
|
-
|
5
|
+
こちらの方が分かりやすいですね。
|
8
|
-
|
9
|
-
そこで、テキストボックスの「フォーカス取得時」に、
|
10
|
-
|
11
|
-
=MemoGotFocus()
|
12
|
-
|
13
|
-
と設定するという2段階になっています。
|
14
6
|
|
15
7
|
|
16
8
|
|
9
|
+
```VB
|
10
|
+
|
11
|
+
Public Function MemoGotFocus() As Long
|
12
|
+
|
13
|
+
With CodeContextObject
|
14
|
+
|
15
|
+
.Parent!LabelMemo.Caption = .ActiveControl.Text
|
16
|
+
|
17
|
+
End With
|
18
|
+
|
17
|
-
|
19
|
+
End Function
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
'このプロシージャは最初に一回実行すればOK
|
26
|
+
|
27
|
+
Public Sub SetFuncFormOnLoad2()
|
28
|
+
|
29
|
+
Const FrmLst = "AA注文在庫,BB注文在庫,CC注文在庫" '対称フォームのリスト
|
30
|
+
|
31
|
+
Const txtLst = "メモ,工場用メモ" '対処テキストボックスのリスト
|
32
|
+
|
33
|
+
Dim Frm
|
34
|
+
|
35
|
+
Dim txt
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
For Each Frm In Split(FrmLst, ",")
|
40
|
+
|
41
|
+
DoCmd.OpenForm Frm, acDesign, , , , acHidden '対称フォームを非表示のデザインモードで開く
|
42
|
+
|
43
|
+
For Each txt In Split(txtLst, ",")
|
44
|
+
|
45
|
+
Forms(Frm).Controls(txt).OnGotFocus = "=MemoGotFocus()" 'イベントプロパティに関数を関連付け
|
46
|
+
|
47
|
+
Next
|
48
|
+
|
49
|
+
DoCmd.Close acForm, Frm, acSaveYes '変更を保存して閉じる
|
50
|
+
|
51
|
+
Next
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
End Sub
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|