I'm trying to find a way to set form/control properties programmatically.
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 programmatically?
here is more code....
'first, open the database in question
Dim frm As Form
Dim prp as Property
Dim acc As Access.Application
Set acc = CreateObject("Access.Application")
acc.OpenCurrentDatabase varPath
''''''''''then open the form in design view
acc.DoCmd.OpenForm rst!ObjectName, View:=acDesign, WindowMode:=acHidden
'''''''''''now access the forms collection (I think that's what this
does...)
Set frm = acc.Forms(strFormName)
''''''''''''''''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