My Assistant
![]() ![]() |
|
|
Mar 18 2012, 12:25 AM
Post
#1
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
I have a wife that is an artist. She would like to be able to have a printout of all the colors she uses. That comes to about 1100. I have many of the RGB codes for the colors in my database and displaying them on a form was no problem. However, I can't seem to figure out how to put them on a report so that each line gives the color name and a textbox that has the color itself. Simply selecting the form and then create > report, doesn't do it.
Hope I'm clear on this because I could sure use some help. It's for personal use and would help me considerably. This post has been edited by Raas: Mar 18 2012, 12:25 AM |
|
|
|
Mar 18 2012, 02:56 AM
Post
#2
|
|
|
UtterAccess Ruler Posts: 1,090 |
Hello there Raas, follow these steps to make your.
1. Create a report based on the table as you normally do. 2. Let say the fieldname for your RGB value is fRGB (example only), then on the design view goto Property Sheet => Other. 3. You will notice that the Name of the textbox is the same as your fieldname (fRGB). 4. Rename the textbox Name, say txtBoxRGB. 5. Click on the detail "band" of the report to see its property. 6. On the On Format Event, make a procedure: CODE Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) me.txtBoxRGB.BackColor = me.txtBoxRGB End Sub Thats it. |
|
|
|
Mar 18 2012, 01:01 PM
Post
#3
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
I appreciate the response. I had looked at the on format event before but must still be missing something. I followed your code exactly (even changing the name of my RGB field from RGBColor to fRGB) and all I get is a report that still lists the RGB values, but no color. Could it be that my RGB field in the table is wrong somehow? It's a text field with no special formatting. I must be missing something here, but what I don't know. Darn, today is my 46th anniversary and I wanted to have this for her. Any help is welcome. I'll try anything. Thank you again!
Well, now I am lost. I set a breakpoint on the code just to see if my event ever fired. Nope! The report never hits the break point. This post has been edited by Raas: Mar 18 2012, 01:05 PM |
|
|
|
Mar 18 2012, 01:10 PM
Post
#4
|
|
|
Access Wiki and Forums Moderator Posts: 47,901 From: SoCal, USA |
Hi,
Well, now I am lost. I set a breakpoint on the code just to see if my event ever fired. Nope! The report never hits the break point. Pardon me for jumping in... Happy Anniversary! (IMG:style_emoticons/default/yayhandclap.gif) Do you have your db in a Trusted Location? Do other codes in the db executes, just not this one? What exaclty does your RGB data look like? Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) |
|
|
|
Mar 18 2012, 01:17 PM
Post
#5
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
Now when I run the report in print preview mode I get an error: The expression On Format you entered as the event property setting produced the following error: Invalid outside procedure." "The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]. There may have been an error evaluating the function, event, or macro."
Then when I click on "OK" another error: "A custom macro in this report has failed to run, and is preventing the report from rendering." I'm not running any macros, and the only code is the single line below: Not a lot of help, is it? My code: Yes, I changed my field name back so that my forms would work. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) Me.txtRGBColor.BackColor = Me.txtRGBColor End Sub |
|
|
|
Mar 18 2012, 01:21 PM
Post
#6
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
Thank you!
Yes, all other break points throughout the database hit no problem. Yes, it is in a trusted location. The data in the table is in a text field and is represented as: 255,255,255 or for light aqua it would be 39,197,185. |
|
|
|
Mar 18 2012, 01:35 PM
Post
#7
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
I do not know what was causing the problem, but I completely deleted the only report and started over, using the code supplied to me (with my name changes) and IT WORKS! Kind of.
Now I just have to figure out why it pulls lots of different colors for backcolor, but the colors are the wrong ones!!!!! (IMG:style_emoticons/default/iconfused.gif) Light Aqua should be a very light blue green not VERY dark purple! |
|
|
|
Mar 18 2012, 01:36 PM
Post
#8
|
|
|
Access Wiki and Forums Moderator Posts: 47,901 From: SoCal, USA |
Hi,
The data in the table is in a text field and is represented as: 255,255,255 or for light aqua it would be 39,197,185. Not sure about the other errors but if your data looks like that, try changing your code to this: Me.txtRGBColor.BackColor = RGB(Me.txtRGBColor) Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) |
|
|
|
Mar 18 2012, 01:56 PM
Post
#9
|
|
|
UtterAccess Ruler Posts: 1,090 |
if it is text and in format 255,255,255, then
CODE Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.txtRGBColor.BackColor = Eval("RGB(" & NZ(Me.txtRGBColor,"255,255,255") & ")") End Sub |
|
|
|
Mar 18 2012, 02:05 PM
Post
#10
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
dbGuy:
I tried that one. It just tells me that I need a red, green, and blue parameter, not a field. This post has been edited by Raas: Mar 18 2012, 02:08 PM |
|
|
|
Mar 18 2012, 02:08 PM
Post
#11
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
Eval("RGB(" & NZ(Me.txtRGBColor,"255,255,255") & ")")
I must be missing something in my interpretation here since now all I get is a listing with the actual RGB values and not colors, again. I've never used an "Eval" before, so I'm not familiar at all with the parameters. What is the "255,255,255" doing for the function and am I supposed to be putting something else there, or is it a formatting mask? |
|
|
|
Mar 18 2012, 02:11 PM
Post
#12
|
|
|
UtterAccess Ruler Posts: 1,090 |
Eval("RGB(" & NZ(Me.txtRGBColor,"255,255,255") & ")") to get the actual long integer value of the text.
nz() is there just in case there is a blank text color in your field. If you are sure you have all the colors on your table then you can safely remove it Me.txtRGBColor.BackColor = Eval("RGB(" & Me.txtRGBColor & ")") This post has been edited by arnelgp: Mar 18 2012, 02:13 PM |
|
|
|
Mar 18 2012, 02:13 PM
Post
#13
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
DUH!!!!!!
I'm sure glad the help here at UtterAccess is so very patient with learners like me!!!!! I had a simple typo on the last posting from arnelgp. So I did what I should have done all along and copy/pasted his code and it works GREAT! Right colors, everything. I would still like to know a bit more about the EVAL statement though. You guys and ladies are the greatest to work with! Thank you! |
|
|
|
Mar 18 2012, 02:13 PM
Post
#14
|
|
|
Access Wiki and Forums Moderator Posts: 47,901 From: SoCal, USA |
Hi,
dbGuy: I tried that one. It just tells me that I need a red, green, and blue parameter, not a field. How about? Dim intArray() As Variant intArray() = Split(Me.txtRGBColor, ",") Me.txtRGBColor.BackColor = RGB(intArray(0), intArray(1), intArray(2)) Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) |
|
|
|
Mar 18 2012, 02:16 PM
Post
#15
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
Eval("RGB(" & NZ(Me.txtRGBColor,"255,255,255") & ")") to get the actual long integer value of the text. nz() is there just in case there is a blank text color in your field. If you are sure you have all the colors on your table then you can safely remove it Me.txtRGBColor.BackColor = Eval("RGB(" & Me.txtRGBColor & ")") I don't know how to use all the goodies in UtterAccess, like the quote fields, etc, but I try. No, I don't have all the RGB values, so I had already put a 'not isNull' check into the code that worked fine. This will be an additional safeguard, however. Again, Great help! Greatly appreciated. My lovely companion will be thrilled! |
|
|
|
Mar 18 2012, 02:16 PM
Post
#16
|
|
|
UtterAccess Ruler Posts: 1,090 |
Happy Anniversary.
Just search for NZ function on the Access help, it will give you the syntax and examples. |
|
|
|
Mar 18 2012, 02:19 PM
Post
#17
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
Will do. Thank you!
|
|
|
|
Mar 18 2012, 02:40 PM
Post
#18
|
|
|
Access Wiki and Forums Moderator Posts: 47,901 From: SoCal, USA |
Hi Raas,
Will do. Thank you! Just curious if you saw my reply earlier to use the Split() function? (IMG:style_emoticons/default/confused.gif) It's just hard to guess at what would work without seeing the actual db. Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) |
|
|
|
Mar 18 2012, 03:33 PM
Post
#19
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
dbguy:
Didn't see it until just now. I'm also going to give that a try and will post the results. Thanks! |
|
|
|
Mar 18 2012, 03:42 PM
Post
#20
|
|
|
UtterAccess Addict Posts: 287 From: Logandale, Nevada |
WOW! Here I couldn't figure out one way, but now have 2 ways that work. Yes, dbguy, that one worked as well, for me.
Thanks all for the feedback and assistance. I'd never even heard of, let alone use, either the Eval or the Split functions. I'm sure there a lot more out there that I know nothing about, nor how to get printed material of them. Oh, well, at least there's help on this forum. This post has been edited by Raas: Mar 18 2012, 03:43 PM |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 18th May 2013 - 09:33 AM |