riti90
Registered User.
- Local time
- Today, 03:44
- Joined
- Dec 20, 2017
- Messages
- 44
Hi Everyone,
I'm trying to built up a Form where I can create Controls for other forms.
Now, I managed to do this but I cannot figure out how to change the "Control Source" or the Control that I created.
Can You please help me with that?
Here's the Code of Command Click And a sample Database
I'm trying to built up a Form where I can create Controls for other forms.
Now, I managed to do this but I cannot figure out how to change the "Control Source" or the Control that I created.
Can You please help me with that?
Here's the Code of Command Click And a sample Database
Code:
Dim frm As Form
Dim ctl As Control
Dim FrmName As String
Dim CtlName As String
Dim CtlType As Long
Dim CtlSource As String
FrmName = Me.cboForms.Value
CtlName = Me.txtFrmFieldName
CtlSource = Me.cboTableFields
DoCmd.OpenForm FormName:=FrmName, View:=acDesign
Set frm = Forms(FrmName)
CtlType = Me.txtCtlType.Value
Set ctl = CreateControl(FormName:=FrmName, ControlType:=CtlType, _
Left:=1440, Top:=2160, Width:=2880, Height:=288)
ctl.Name = CtlName
' Switch to form view
[COLOR="red"]Forms(FrmName).Controls(ctl).ControlSource = CtlSource[/COLOR]
'RunCommand acCmdFormView
' Or save the form, close and reopen it
DoCmd.Close ObjectType:=acForm, ObjectName:=FrmName, Save:=acSaveYes
DoCmd.OpenForm FormName:=FrmName, View:=acNormal
'Forms(strForm).Controls(strCtl).Value = "Hello World"