Controls Properties

  • Thread starter Thread starter JamesJ
  • Start date Start date
J

JamesJ

Hi. I trying to set the BackStyle property of several controls at
once and opposed to referencing each control using the On
Click of a command button. I haven't had any luck. I've tried
some examples that I thought might work but...
I gathered I should be using With..End With or For Each...Next
or both to cycle through the Controls Collection.
Any help will be a appreciated.

James
 
Usually, you can use the Tag property to identify those fields that your For
Next will operate upon. (ex tag = "BG")

Dim ctl As Control
For each ctl In me.controls
If Tag = "BG" Then
ctl.BackColor = RGB(...your color)
End if
Next ctl
hth
Al Camp
 
James,
Just enter BG in Tag property, not "BG" (with quotes)

Also, disregard my previous post, and use this code instead...

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "BG" Then
ctl.BackColor = QBColor(13)
End If
Next ctl

That should do it...
Al Camp
 
Thanks, it works fine.

James

Al Camp said:
James,
Just enter BG in Tag property, not "BG" (with quotes)

Also, disregard my previous post, and use this code instead...

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "BG" Then
ctl.BackColor = QBColor(13)
End If
Next ctl

That should do it...
Al Camp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top