OnFormat Code needed

G

Guest

Access 03, WinXP.

Occasionally we group staff and students into different teams. The team
names (all colors) remain the same. We then print out reports (name tags)
where the person's name is in the color of the team name. Is there a way to
change the color on the fly using a field in the team name table that holds
the RGB code of the
color?

Someone told me I could bind the color to a control in the detail section
and use code in the On Format event to set the color of a text box, but I
don't know where to start to write code like that.

Many thanks in advance~
 
A

Al Campagna

Kirstin,
Well, that's a interesting question.

You can create a table field called TeamColor (Numeric Integer)

Report OnFormat...

Using Forecolor values from properties box... TeamColor = 255 (Red)
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
YourFieldName.ForeColor = TeamColor
End Sub

Using QBColors TeamColor =1 thru 15
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
YourFieldName.ForeColor = QBColor(TeamColor)
End Sub

Using RGB... need 3 variables RGB1, RGB2, and RGB3, each possible 0-255.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
YourFieldName.ForeColor = RGB(RGB1,RGB2,RGB3)
End Sub

I'd try an OptionGroup on continuous form with colored options that set
the color value/values of that person's record.
They will be colored "on the fly" in the OnFormat event.

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html
"Find a job that you love... and you'll never work a day in your life."
 
M

Marshall Barton

Kirstin said:
Access 03, WinXP.

Occasionally we group staff and students into different teams. The team
names (all colors) remain the same. We then print out reports (name tags)
where the person's name is in the color of the team name. Is there a way to
change the color on the fly using a field in the team name table that holds
the RGB code of the
color?

Someone told me I could bind the color to a control in the detail section
and use code in the On Format event to set the color of a text box, but I
don't know where to start to write code like that.


Assuming the color code field in the team table is in your
report's record source table/query, you can just add an
invisible text box to the report (team group geader section?
or detail section?). Bind this color text box to the color
code field. Then the detail section's Format event
procedure would only need one line of code:
Me.nametextbox.ForeColor = Me.colortextbox

Your question implies that you may need additional help with
the details of all this, but I don't like to speculate about
what you might not know so post back with a specific
question if you run into a stumbling block.
 
A

Al Campagna

Kirstin,
Using QBColors TeamColor =1 thru 15
The QBColor can range from 0-15, not 1-15.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html
"Find a job that you love... and you'll never work a day in your life."

Al Campagna said:
Kirstin,
Well, that's a interesting question.

You can create a table field called TeamColor (Numeric Integer)

Report OnFormat...

Using Forecolor values from properties box... TeamColor = 255 (Red)
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
YourFieldName.ForeColor = TeamColor
End Sub

Using QBColors TeamColor =1 thru 15
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
YourFieldName.ForeColor = QBColor(TeamColor)
End Sub

Using RGB... need 3 variables RGB1, RGB2, and RGB3, each possible
0-255.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
YourFieldName.ForeColor = RGB(RGB1,RGB2,RGB3)
End Sub

I'd try an OptionGroup on continuous form with colored options that set
the color value/values of that person's record.
They will be colored "on the fly" in the OnFormat event.

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html
"Find a job that you love... and you'll never work a day in your life."
 

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

Top