rlievesley
Technical User
Hi,
I'm starting to learn vba in access, and wonder if anybody can help me with this question.
I have previously created some VBA code in excel which dynamically adds controls to an existing form.
I want to use similar code in Access, but the Form.Controls.Add method I used in Excel VBA is not supported.
For example, in Excel, the code I used to add a label called lblGEIName to UserForm1 was:
dim theGEINameLabel
Set theGEINameLabel = UserForm1.Controls.Add("Forms.Label.1", "lblGEIName")
With theGEINameLabel
.Left = 50
.Top = 100
.Caption = "GEI Name"
End With
UserForm1.Show
This code was in a sub in a module, and when called would display the form with the label.
When I try the same code in Access VBA, I get a "Complile Error, Method or Data Member Not Found" on the Add section of UserForm1.Controls.Add
Does anybody know how I can get to dynmically add controls to a form in access like this?
Many thanks for any help
Rob
I'm starting to learn vba in access, and wonder if anybody can help me with this question.
I have previously created some VBA code in excel which dynamically adds controls to an existing form.
I want to use similar code in Access, but the Form.Controls.Add method I used in Excel VBA is not supported.
For example, in Excel, the code I used to add a label called lblGEIName to UserForm1 was:
dim theGEINameLabel
Set theGEINameLabel = UserForm1.Controls.Add("Forms.Label.1", "lblGEIName")
With theGEINameLabel
.Left = 50
.Top = 100
.Caption = "GEI Name"
End With
UserForm1.Show
This code was in a sub in a module, and when called would display the form with the label.
When I try the same code in Access VBA, I get a "Complile Error, Method or Data Member Not Found" on the Add section of UserForm1.Controls.Add
Does anybody know how I can get to dynmically add controls to a form in access like this?
Many thanks for any help
Rob