Hi
I have an application that has many forms. I am trying to standardise the appearance (formatting) of each form.
Rather than run the new code in each form I have created a table with the new formatting for each object. (I did this to allow for any future changes in just one location).
I then created a public function as follows:
Public Function ChangeFormColours()
Dim Header As Long
Dim Detail As Long
Dim TextBox As Long
Dim TextFont As Long
Dim tb As Control
Dim cbo As Control
Header = DLookup("Header", "tblFormColours")
Detail = DLookup("Detail", "tblFormColours")
TextBox = DLookup("TextBox", "tblFormColours")
TextFont = DLookup("TextFont", "tblFormColours")
For Each tb In Me.Controls
If TypeOf tb Is TextBox Then
tb.BackColor = TextBox
tb.ForeColor = TextFont
End If
Next
For Each cbo In Me.Controls
If TypeOf cbo Is ComboBox Then
tb.BackColor = TextBox
tb.ForeColor = TextFont
End If
Next
Me.FormHeader.BackColor = Header
Me.Detail.BackColor = Detail
End Function
Obviously, the use of me is inappropriate and I want to be able to use the form name (as it loads) in this code where the me exists, but am stumped.
I am calling the function on Form Load.
Would appreciate any assistance.
Thank you
David
I have an application that has many forms. I am trying to standardise the appearance (formatting) of each form.
Rather than run the new code in each form I have created a table with the new formatting for each object. (I did this to allow for any future changes in just one location).
I then created a public function as follows:
Public Function ChangeFormColours()
Dim Header As Long
Dim Detail As Long
Dim TextBox As Long
Dim TextFont As Long
Dim tb As Control
Dim cbo As Control
Header = DLookup("Header", "tblFormColours")
Detail = DLookup("Detail", "tblFormColours")
TextBox = DLookup("TextBox", "tblFormColours")
TextFont = DLookup("TextFont", "tblFormColours")
For Each tb In Me.Controls
If TypeOf tb Is TextBox Then
tb.BackColor = TextBox
tb.ForeColor = TextFont
End If
Next
For Each cbo In Me.Controls
If TypeOf cbo Is ComboBox Then
tb.BackColor = TextBox
tb.ForeColor = TextFont
End If
Next
Me.FormHeader.BackColor = Header
Me.Detail.BackColor = Detail
End Function
Obviously, the use of me is inappropriate and I want to be able to use the form name (as it loads) in this code where the me exists, but am stumped.
I am calling the function on Form Load.
Would appreciate any assistance.
Thank you
David