I'm trying to find a way to set form/control properties programmaticall y.
In a nut shell:
1. Open a database
2. Open a form in design view
3. Do something like this:
For Each prp In frm.Properties
If prp.Name = rst!PropName Then
prp = rst!ChangeTo
End If
Next
(this actually works for Form properties)
BUT .. I'm having a hard time with the Control properties...
How to access the properties of controls programmaticall y?
here is more code....
'first, open the database in question
Dim frm As Form
Dim prp as Property
Dim acc As Access.Applicat ion
Set acc = CreateObject("A ccess.Applicati on")
acc.OpenCurrent Database varPath
''''''''''then open the form in design view
acc.DoCmd.OpenF orm rst!ObjectName, View:=acDesign, WindowMode:=acH idden
'''''''''''now access the forms collection (I think that's what this
does...)
Set frm = acc.Forms(strFo rmName)
''''''''''''''' 'this is where I get lost...
For Each ctl In frm.Controls
'''''''''''''do I need For ... Each if I know what I'm looking for?
If ctl = acCommandButton Then 'error: This property isn't available in
design view
For Each prp In ctl.Properties
Debug.Print prp.Name & " = " & prp.Value
prp = rst!ChangeTo <<== rst has all the ChangeTo values
Debug.Print prp.Name & " = " & prp.Value
Debug.Print ctl.Name & " changed"
Next
End If
Next
In a nut shell:
1. Open a database
2. Open a form in design view
3. Do something like this:
For Each prp In frm.Properties
If prp.Name = rst!PropName Then
prp = rst!ChangeTo
End If
Next
(this actually works for Form properties)
BUT .. I'm having a hard time with the Control properties...
How to access the properties of controls programmaticall y?
here is more code....
'first, open the database in question
Dim frm As Form
Dim prp as Property
Dim acc As Access.Applicat ion
Set acc = CreateObject("A ccess.Applicati on")
acc.OpenCurrent Database varPath
''''''''''then open the form in design view
acc.DoCmd.OpenF orm rst!ObjectName, View:=acDesign, WindowMode:=acH idden
'''''''''''now access the forms collection (I think that's what this
does...)
Set frm = acc.Forms(strFo rmName)
''''''''''''''' 'this is where I get lost...
For Each ctl In frm.Controls
'''''''''''''do I need For ... Each if I know what I'm looking for?
If ctl = acCommandButton Then 'error: This property isn't available in
design view
For Each prp In ctl.Properties
Debug.Print prp.Name & " = " & prp.Value
prp = rst!ChangeTo <<== rst has all the ChangeTo values
Debug.Print prp.Name & " = " & prp.Value
Debug.Print ctl.Name & " changed"
Next
End If
Next
Comment