Last active
March 1, 2021 12:50
-
-
Save felixlindemann/12da432d706f64fd220a to your computer and use it in GitHub Desktop.
VBA: Create Userform in MS-Access Programatically - Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub demo_Modul_Userform() | |
Dim frm As Object | |
Set frm = getEmptyForm() | |
frm.Properties("Height") = 100 | |
frm.Properties("Width") = 200 | |
'add control | |
Dim NewButton As Msforms.CommandButton | |
Set NewButton = frm.Designer.Controls.Add("Forms.CommandButton.1") | |
With NewButton | |
.Caption = "Click Me" | |
.Left = 60 | |
.Top = 40 | |
End With | |
With frm.CodeModule | |
Line = .CountOfLines | |
.InsertLines Line + 1, "Sub " & NewButton.Name & "_Click()" | |
.InsertLines Line + 2, " call demo_Modul_Userform_CommandButtonAction" | |
.InsertLines Line + 3, "End Sub" | |
End With | |
showForm frm | |
closeForm frm | |
End Sub | |
Public Sub demo_Modul_Userform_CommandButtonAction() | |
MsgBox "Hello World" | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment