-
Notifications
You must be signed in to change notification settings - Fork 11
/
Access - VBA Controls.vb
74 lines (58 loc) · 1.52 KB
/
Access - VBA Controls.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
'
' Use this coe to create a singe new button
' in your access or
' Penenue (2018)
'
Sub create_NewButton()
'Set parameter
Dim btn As Control
'Open form in hidden mode
DoCmd.OpenForm "Google", acDesign, , , acFormEdit, acHidden
On Error Resume Next
'Create button
Set btn = CreateControl("Google", acCommandButton, acDetail)
'Move
k.Move 2500, 2500, 1500, 700
'Get control name
this_name = k.Name
'Add caption
Forms("Google").Controls(this_name).Caption = "Google"
'Close form
DoCmd.Close acForm, "Google", acSaveYes
End Sub
'
' Use this coe to create mutipe buttons
' in your access or
'
Sub create_NewButtons()
'Set array
Dim btn(0 To 1) As Control
'Form & control
Dim o As Form
Dim f As Control
Dim leftMove As Long
leftMove = 2000
'Open form hidden
DoCmd.OpenForm "Google", acDesign, , , acFormEdit, acHidden
Set o = Forms("Google")
For i = 0 To 1
'Create buttons
Set btn(i) = CreateControl("Google", acCommandButton, acDetail)
'Set object to control
Set f = Forms("Google").Controls(i)
'Move controls
f.Move 1000, leftMove
'When control is index 1, put x name and caption
If i = 0 Then
f.Name = "Email_Button"
f.Caption = "Email"
Else
f.Name = "Validate_Button"
f.Caption = "Validate"
End If
'Move below
leftMove = leftMove + 1000
Next i
'Close form
DoCmd.Close acForm, "Google", acSaveYes
End Sub