Sub SetProperty(propertyParent As String, propertyName As String, propertyValue As Variant)
Me.Controls(propertyParent).Properties(propertyName) = propertyValue
For your second idea, something like Call SetProperties("txt_inv_no","Top",510,"Left",10695) is not so feasible because subs and functions typically require a fixed set of criteria parameters.
For your third idea, passing an array of properties about one control, here is a good example:
Function Control_Enum(Ctrl As Control) As Control
On Error Resume Next
Dim CT As Long
Set Control_Enum = Ctrl
For CT = 0 To Control_Enum.Properties.Count - 1
Debug.Print Control_Enum.Properties(CT).Name; "=";
If Err.Number Then Err.Clear: Debug.Print
Within a form or report, if you use something like:
It should print a list of the control's properties and their values in the Debug Window.
Thank you! I am going to work on it right now, and this was PERFERCT timing .
I wish Access had the same type of thing as Crystal Reports where you can define multiple versions of a section i.e. Page header A, Page Header B and just dynamically choose which, or even both, to display. Instead i'm moving around a whole bunch of controls to accomplish the same thing.
And on an unrelated note, when will the end users ever understand the effort required to produce "simple" reports?
Here is the code to the second function, it seems so simple!
Sub SetProperties(ctlpropertyParent As Control, strPropertyArray As String)
Dim varPropertyArray As Variant
Dim intI As Integer
varPropertyArray = Split(strPropertyArray, ",")
For intI = 0 To UBound(varPropertyArray) Step 2
ctlpropertyParent.Properties(varPropertyArray(intI)) = varPropertyArray(intI + 1)
I know all of this may seem unnecessary to some of you, but there is a reason to my madness.
I have created a report that requires me moving around a lot controls, and as I mentioned in my previous post, this would all be avoided if Access allowed multiple sections. One other way of doing what I'm doing i guess would be to, instead of moving the controls, just create duplicates in teh right places and turn them on or off.
Maybe I will change all this stuff around once the design is set, although it doesn't seem to be affecting performance, and it's moving about 25 controls on every page of my report. But for design purposes, it is the only way I can make sense of everything i'm doing.