And I tried to attach, but it keeps failing to upload.
I've compacted and I zipped, is there anything else I can try?
And I tried to attach, but it keeps failing to upload.
I've compacted and I zipped, is there anything else I can try?
Alright, I have a sample of the database attached with the main objects that are needed for this coloring project/coding.
there's confusion here. this code of yours:looks at a header control. I was under the impression that there was one report for each TEAM, and no other factors. That's not the case. One report is for one team, and you have records that pertain to different activities for that one team. So what you should have said was that you want colors based off the different activities for one team. The thread would've been shorter and less time consuming for you. Just FYI!Code:Private Sub Report_Load() If Me.Team = "Atlanta Hawks" Then Me.Detail.BackColor = vbRed If Me.Team = "Boston Celtics" Then Me.Detail.BackColor = vbGreen End If End If End Sub
so you have 2 subreports. neither one has anything to do with the main report, which is really just a header control and nothing else. With all that said, to use the code you've been using, it might work if you changed the back color of the SUBFORMS, and referenced their controls as well. That's the criteria, the way I see it, NOT the header label control.
Right now, it's doing exactly what you asked!
Don't worry about any of that. I have some stuff hidden that might be keeping you from seeing what is actually going on.there's confusion here. this code of yours:looks at a header control. I was under the impression that there was one report for each TEAM, and no other factors. That's not the case. One report is for one team, and you have records that pertain to different activities for that one team. So what you should have said was that you want colors based off the different activities for one team. The thread would've been shorter and less time consuming for you. Just FYI!Code:Private Sub Report_Load() If Me.Team = "Atlanta Hawks" Then Me.Detail.BackColor = vbRed If Me.Team = "Boston Celtics" Then Me.Detail.BackColor = vbGreen End If End If End Sub
so you have 2 subreports. neither one has anything to do with the main report, which is really just a header control and nothing else. With all that said, to use the code you've been using, it might work if you changed the back color of the SUBFORMS, and referenced their controls as well. That's the criteria, the way I see it, NOT the header label control.
Right now, it's doing exactly what you asked!
Anyways, I have switched to using Case Statements. Not quite sure how to reference my table 'NBATeamColors' and pull the colors that way.
Here is my code:Code:Private Sub Report_Load() Select Case Me.Team Case "Atlanta Hawks" Me.Team.ForeColor = vbRed Case "Boston Celtics" Me.Team.ForeColor = vbBlue Case "Charlotte Bobcats" Me.Team.ForeColor = vbBlack Case "Chicago Bulls" Me.Team.ForeColor = vbWhite End Select End Sub
so you got it fixed?
You know what, I might just ditch this table and keep using this Case Select statements. Working out pretty well so far and really don't see any problems with it other than it will take awhile to change the colors for 30 teams and however many pieces of the report I want to change based on the team.
Unless you all recommend using the table. It just seems as though there will be more code I would have to write if I went that route.
Thanks for the help
I think Adam's table idea is the way to go. Even if you don't include it in the report data and do lookups, it's much more maintainable. Presumably you'll have other forms and reports where you might want to do something similar. It's a lot more flexible to just go to the table to add a team, change colors, etc, than to have to change this code everywhere it might appear.
By the way, you'll have less code with the table, not more. With your method, you'll have 30 Case statements, so at least that many lines. With the table and Adam's DLookup, you have one line.
I will note that I've never had success with color represented that way (#FFFFFF). I've only gotten numerical equivalents to work. Attached is a table I use to dynamically set the colors of labels representing cars, based on their status. Maybe it's because I've only tried with 2000.
it's not mine, it's yours, sir. Remember?
And sir, the first thing that I would recommend about this database (and I'm being serious here) is to NOT think so much about it.
I remember talking to you a while back about this, and unless you know this coach/scout really well, remember that people right now will do almost anything to get something for free. And you're doing this for free (or has that changed since then?).
I don't want to say that this guy is using you in this way, but I will say that he wouldn't get more than a couple hours of advice out of me unless I got a check in the mail.
Just be careful bud...I surely wouldn't want to see you waste your time on this, just to find out that the future value of the relationship with this guy doesn't yield anything other than a "thank you". You sure have invested a lot more time than the average bear would.
You suggested the table in the first response Adam, I just suggested joining it in a query rather than using DLookup's. Credit given where credit is due!
You got me. Okay...
and hey, I'm 99% sure I remember alpha numerics working in code when I did an alternating color pattern for a report once. I've never had 2000 though. Only 03 and up. I'll have to confirm that sometime. Thanks. Interesting thing too, that only the integer equivs work in 2000. Are you sure about that? Have you tried them with and without the # signs? And you're talking about control object colorings that are set in code?
I briefly tested a variation of what you posted and got a type mismatch error. Switched it to the numeric value and it worked fine. When you select a color in the properties window it gives you the number, and I've noticed in 2007 it gives the "#" value.
I found a website that has the Access 2007 numerical equivalents for certain colors, so I have just been using those.
More importantly, I haven't the slightest clue as to how to reference the table with the color codes. Could one of you all be kind enough to write up a sample line of code as to how this is done?
Adam, what I'm working on now is for myself. That guy has his copy I finished back in November, looking back, sure I would love to have been paid, but for me knowing a "NBA guy" was more important and I didn't want to screw that up.
With that said, when he comes asking for more I will be asking for a check.
Could I set this table up to display a background image based on the team as well?
Sticking with the Case Select. Can't figure out how to reference the table or even how to reference a particular cell in the table.