By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,704 Members | 1,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,704 IT Pros & Developers. It's quick & easy.

changing fields colours

P: n/a
I need to create a button which changes the back colour and the font colour
and type of several fiels in a form, This is the way I would normally do it:
[Date].Backcolor = 11112121
[Date].tabstop = True
[Customer No].Backcolor =
etc

is there a way I can do it for all of them grouped together, given that the
whole group needs to change to the same colours?

Thanks
Paolo
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

Paolo wrote:
I need to create a button which changes the back colour and the font colour and type of several fiels in a form, This is the way I would normally do it: [Date].Backcolor = 11112121
[Date].tabstop = True
[Customer No].Backcolor =
etc

is there a way I can do it for all of them grouped together, given that the whole group needs to change to the same colours?

Thanks
Paolo


Hi Paulo,
You can set the tag property of the control to a value to check
for and then use a for each statement like below:

'************************************************* ***
Dim x As Control

For Each x In Controls
If x.Tag = "True" then
x.Backcolor = 11112121
x.tabstop = True
End if
Next x
'************************************************* ***

In the example above, it is assumed that the Tag value has True typed
into it. Hope this helps.

David Hodgkins
JSTAR Software Solutions - Home of AutoCompact
www.jstarsoftware.com

Nov 13 '05 #2

P: n/a

"Paolo" <pr*****@netspace.net.au> schreef in bericht
news:42**********@news.melbourne.pipenetworks.com. ..
I need to create a button which changes the back colour and the font colour and type of
several fiels in a form, This is the way I would normally do it:
[Date].Backcolor = 11112121
[Date].tabstop = True
[Customer No].Backcolor =
etc

is there a way I can do it for all of them grouped together, given that the whole group
needs to change to the same colours?


You could use something like

Dim ctrl As Control
For Each ctrl In Me.Controls
Select Case ctrl.Name
Case "Date", "Customer No"
ctrl.Backcolor = 11112121
ctrl.tabstop = True
End Select
Next

--
Hope this helps
Arno R

Nov 13 '05 #3

P: n/a
On Sat, 19 Mar 2005 19:06:46 +1100, Paolo wrote:
I need to create a button which changes the back colour and the font colour
and type of several fiels in a form, This is the way I would normally do it:
[Date].Backcolor = 11112121
[Date].tabstop = True
[Customer No].Backcolor =
etc

is there a way I can do it for all of them grouped together, given that the
whole group needs to change to the same colours?

Thanks
Paolo


You've received several replies by now, telling you how to change
control properties, so I'll call your attention to another aspect of
database design you may not be aware of... your use of the word "Date"
as a field name.

Date is a reserved Access/VBA/Jet word and should not be used as a
field name.
See the Microsoft KnowledgeBase article for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #4

P: n/a
Thanks for the replies guys..

Fred: the control I typed was just an example the controls I have to change
in the form are different ones. But thank you anyway I didn't know about the
date word, good thing for me to know.

Arno I can't really use the function as I have to change different groups
of control inside of the same form.

David yours seems to be what I need but I don't know what the Tag is...
sorry I am very green with VBA and it's hard for me to grasp some concepts..
Again thanks guys

"fredg" <fg******@example.invalid> wrote in message
news:o2******************************@40tude.net.. .
On Sat, 19 Mar 2005 19:06:46 +1100, Paolo wrote:
I need to create a button which changes the back colour and the font
colour
and type of several fiels in a form, This is the way I would normally do
it:
[Date].Backcolor = 11112121
[Date].tabstop = True
[Customer No].Backcolor =
etc

is there a way I can do it for all of them grouped together, given that
the
whole group needs to change to the same colours?

Thanks
Paolo


You've received several replies by now, telling you how to change
control properties, so I'll call your attention to another aspect of
database design you may not be aware of... your use of the word "Date"
as a field name.

Date is a reserved Access/VBA/Jet word and should not be used as a
field name.
See the Microsoft KnowledgeBase article for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.


Nov 13 '05 #5

P: n/a
Tag is a property of a control {button, text box etc.}. It shows on the
'Options' tab of the properties window when a control is selected.
Pete.

"Paolo" <pr*****@netspace.net.au> wrote in message
news:42********@news.melbourne.pipenetworks.com...
Thanks for the replies guys..

Fred: the control I typed was just an example the controls I have to
change
in the form are different ones. But thank you anyway I didn't know about
the
date word, good thing for me to know.

Arno I can't really use the function as I have to change different groups
of control inside of the same form.

David yours seems to be what I need but I don't know what the Tag is...
sorry I am very green with VBA and it's hard for me to grasp some
concepts..
Again thanks guys

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.