473,378 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

User selectable color spec in data fields on printed reports

MLH
I have a number of reports that are essentially black 'n
white prepared forms (picture an IRS form 1040). The
data fields are overlaid onto the report fields in the
correct positions and I would to empower the user to
use blue/red/black - maybe more - as the forecolor
property for the textbox controls holding data so that
the black & white forms will have all the printed data
shown in the desired color.

I put a textbox control on the report (rptENF260) named
DataColor. Then I tried setting a single datafield textbox's
ForeColor property to =Me!DataColor. Well, that didn't work.
So I tried =Forms!rptENF260!DataColor and just
Forms!rptENF260!DataColor. Access 97 HELP says
any expression evaluating to a numeric value can be
used. I can't seem to find one that works.
Nov 13 '05 #1
13 1840
MLH
Further testing proves that I cannot even put this into the ForeColor
property setting: =16711680*10/10. I'm sure that's a numeric
expression.

Nov 13 '05 #2
MLH
I am thinking of setting the desired report textbox fields'
ForeSkin property to desired value from within code. I know
its a lot of typing but I cannot seem to get around the
property settings box limitation allowing ONLY a number
to be typed in the ForeColor property setting field.

Would someone like to contribute a code snippet that
lists only those textbox controls on a report having specified
ForeColor property setting value of 16711680?
Nov 13 '05 #3
MLH
>Would someone like to contribute a code snippet that
lists only those textbox controls on a report having specified
ForeColor property setting value of 16711680?


OK, I'll have a go at it...

Private Sub ListControlsBttn_Click()
'************************************************* ************************
' Purpose: Run the Controls Collection for user-specified form.
' The controls collection is a form's default collection.
'************************************************* ************************
On Error GoTo ListControlsBttn_ClickError
Dim ThisForm As String
ThisForm = Me.Name
Dim I As Integer, intHowmany As Integer, WhichRept As String

Msg = "Enter report name." ' Set prompt.
Title = "Report Name?" ' Set title.
Defvalue = "rptENF260" ' Set default return
value.
WhichRept = InputBox$(Msg, Title, Defvalue) ' Get user input.
If WhichRept = "" Then Exit Sub
For I = 0 To Reports(WhichRept).Count - 1
intHowmany = intHowmany + 1
If Reports(WhichRept)(I).ForeColor = 16711680 And
Reports(WhichRept)(I).ControlType = acTextBox Then
Debug.Print intHowmany; ") "; Reports(WhichRept)(I).Name,
Reports(WhichRept)(I).ControlType
End If
Next I

ExitButton11_Click:
Exit Sub

ListControlsBttn_ClickError:
Dim r As String, k As String, Message3 As String
r = "The following unexpected error occurred in Sub
ListControlsBttn_Click, CBF on " & ThisForm & "."
k = CRLF & CRLF & "Error # " & Trim$(str$(Err)) & ": " & Quote &
Error$ & Quote
Message3 = r & k
MsgBox Message3, 48, "Unexpected Error - " & MyApp$ & ", rev. " &
MY_VERSION$
Resume ExitButton11_Click

End Sub

Problem I'm having is the process stops prematurely - after listing
about 20 controls in the immediate window - complaining of an error
#438 ==> "Object doesn't support this property or method." Hmmmm???
Dunno what that's about. I'm kind-a-restricting the objects to only
textbox's (I thought). Wonder why one of the textboxes will not
support some property or method that the others seem to support
wholeheartedly?
Nov 13 '05 #4
MLH
Well then, try this...

Private Sub ListControlsBttn_Click()
'************************************************* ************************
' Purpose: Run the Controls Collection for user-specified form.
' The controls collection is a form's default collection.
'************************************************* ************************
On Error GoTo ListControlsBttn_ClickError
Dim ThisForm As String
ThisForm = Me.Name
Dim I As Integer, intHowmany As Integer, WhichRept As String

Msg = "Enter report name." ' Set prompt.
Title = "Report Name?" ' Set title.
Defvalue = "rptENF260" ' Set default return
value.
WhichRept = InputBox$(Msg, Title, Defvalue) ' Get user input.
If WhichRept = "" Then Exit Sub
For I = 0 To Reports(WhichRept).Count - 1
intHowmany = intHowmany + 1
If Reports(WhichRept)(I).ControlType = acTextBox Then
If Reports(WhichRept)(I).ForeColor = 16711680 Then
Debug.Print intHowmany; ") ";
Reports(WhichRept)(I).Name, Reports(WhichRept)(I).ControlType
End If
End If
Next I

ExitButton11_Click:
Exit Sub

ListControlsBttn_ClickError:
Dim r As String, k As String, Message3 As String
r = "The following unexpected error occurred in Sub
ListControlsBttn_Click, CBF on " & ThisForm & "."
k = CRLF & CRLF & "Error # " & Trim$(str$(Err)) & ": " & Quote &
Error$ & Quote
Message3 = r & k
MsgBox Message3, 48, "Unexpected Error - " & MyApp$ & ", rev. " &
MY_VERSION$
Resume ExitButton11_Click

End Sub

Nov 13 '05 #5
MLH
Wow! Great suggestion, mlh! Worked perfectly.
Thanks for taking the time to lend a hand. You're
a swell guy.
Nov 13 '05 #6
rkc
MLH wrote:
I am thinking of setting the desired report textbox fields'
ForeSkin property to desired value from within code.


What version of Access are you using?
Nov 13 '05 #7
MLH
ACCESS 97.
I am really hoping for an easier solution than what I'm having to
do in code (example below)
MLH wrote:
I am thinking of setting the desired report textbox fields'
ForeSkin property to desired value from within code.


What version of Access are you using?


Private Sub Report_Open(Cancel As Integer)
'************************************************* ******************
'************************************************* ******************
On Error GoTo Err_Report_Open
Dim ThisReport As String
ThisReport = Me.Name
GlobalString = ThisReport
ThisReportsDataColor = DLookup("[DataColor]", "tblReportColors",
"[ReportName]=GetGlobalString() AND [RptUsed]=True")

7 Me!VehicleMake.ForeColor = ThisReportsDataColor
9 Me!VehicleYear.ForeColor = ThisReportsDataColor
11 Me!MotorNum.ForeColor = ThisReportsDataColor
13 Me!SerialNum.ForeColor = ThisReportsDataColor
16 Me!TagNum.ForeColor = ThisReportsDataColor
18 Me!TagYear.ForeColor = ThisReportsDataColor
20 Me!TagState.ForeColor = ThisReportsDataColor
22 Me!TagCounty.ForeColor = ThisReportsDataColor
24 Me!VehicleValue.ForeColor = ThisReportsDataColor
26 Me!InspStickNum.ForeColor = ThisReportsDataColor
28 Me!InspStickState.ForeColor = ThisReportsDataColor
30 Me!InspStickExpDate.ForeColor = ThisReportsDataColor
32 Me!OtherReason.ForeColor = ThisReportsDataColor
33 Me!DateLeft.ForeColor = ThisReportsDataColor
34 Me!VehicleLocationName.ForeColor = ThisReportsDataColor
36 Me!TowCoAddr.ForeColor = ThisReportsDataColor
38 Me!LocPhone.ForeColor = ThisReportsDataColor
39 Me!OwnrEvidence.ForeColor = ThisReportsDataColor
40 Me!VehRemark.ForeColor = ThisReportsDataColor
47 Me!AuthorizedBy.ForeColor = ThisReportsDataColor
49 Me!AEAddress.ForeColor = ThisReportsDataColor
79 Me!Text160.ForeColor = ThisReportsDataColor
87 Me!MyTowCoName.ForeColor = ThisReportsDataColor
88 Me!MyTowCoAddr.ForeColor = ThisReportsDataColor
161 Me!SigningAuthority.ForeColor = ThisReportsDataColor
162 Me!Text248.ForeColor = ThisReportsDataColor

Exit_Report_Open:
Exit Sub

Err_Report_Open:
Dim r As String, k As String, Message3 As String
r = "The following unexpected error occurred in Sub Report_Open,
CBR on " & ThisReport & "."
k = CRLF & CRLF & str$(Err) & ": " & Quote & Error$ & Quote
Message3 = r & k
MsgBox Message3, 48, "Unexpected Error, Exiting Report - " &
MyApp$ & ", rev. " & MY_VERSION$
Resume Exit_Report_Open

End Sub

Having to do that in the open event code of EVERY report is
a bear. Surely, I can handle this in the ForeColor property???
Nov 13 '05 #8
rkc
MLH wrote:
ACCESS 97.
I am really hoping for an easier solution than what I'm having to
do in code (example below)


Do you have any lines on your report?
Nov 13 '05 #9
MLH
Yes sir, I do.

Do you have any lines on your report?


Nov 13 '05 #10
rkc
MLH wrote:
Yes sir, I do.
Do you have any lines on your report?


Is a line a control?
Does a line have a forecolor property?

Nov 13 '05 #11
MLH
I don't think you understand.
Nov 13 '05 #12
rkc
MLH wrote:
I don't think you understand.


You can be confusing.
Enlighten me.

Private Sub SetAllTextBoxForeColor (clr As Long)

Dim ctl As Access.Control

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.ForeColor = clr
End If
Next

Set ctl = Nothing

End Sub
Nov 13 '05 #13
MLH
You sure hit the nail right on the head. Thx for bringing
me around. Six replies above this one, I showed you
my donkey approach (stubborn ass approach)...
7 Me!VehicleMake.ForeColor = ThisReportsDataColor
9 Me!VehicleYear.ForeColor = ThisReportsDataColor
11 Me!MotorNum.ForeColor = ThisReportsDataColor
13 Me!SerialNum.ForeColor = ThisReportsDataColor
16 Me!TagNum.ForeColor = ThisReportsDataColor
18 Me!TagYear.ForeColor = ThisReportsDataColor
20 Me!TagState.ForeColor = ThisReportsDataColor
22 Me!TagCounty.ForeColor = ThisReportsDataColor
24 Me!VehicleValue.ForeColor = ThisReportsDataColor
26 Me!InspStickNum.ForeColor = ThisReportsDataColor
28 Me!InspStickState.ForeColor = ThisReportsDataColor
30 Me!InspStickExpDate.ForeColor = ThisReportsDataColor
32 Me!OtherReason.ForeColor = ThisReportsDataColor
33 Me!DateLeft.ForeColor = ThisReportsDataColor
34 Me!VehicleLocationName.ForeColor = ThisReportsDataColor
36 Me!TowCoAddr.ForeColor = ThisReportsDataColor
38 Me!LocPhone.ForeColor = ThisReportsDataColor
39 Me!OwnrEvidence.ForeColor = ThisReportsDataColor
40 Me!VehRemark.ForeColor = ThisReportsDataColor
47 Me!AuthorizedBy.ForeColor = ThisReportsDataColor
49 Me!AEAddress.ForeColor = ThisReportsDataColor
79 Me!Text160.ForeColor = ThisReportsDataColor
87 Me!MyTowCoName.ForeColor = ThisReportsDataColor
88 Me!MyTowCoAddr.ForeColor = ThisReportsDataColor
161 Me!SigningAuthority.ForeColor = ThisReportsDataColor
162 Me!Text248.ForeColor = ThisReportsDataColor

I'm finding more and more often that when it seems to me that
someone is confused about something I've said - it turns out I'm
the one who is confused. You need no enlightening - you knew
precisely what I needed. The code below proves it. Thx, rkc
for having the patience to help me out here. You were trying to
teach me to fish instead of tossing me a cod - somehow, I just
didn't get it. Now that I do get it, I appreciate your effort.
On Sat, 05 Nov 2005 02:09:17 GMT, rkc
<rk*@rochester.yabba.dabba.do.rr.bomb> wrote:
MLH wrote:
I don't think you understand.


You can be confusing.
Enlighten me.

Private Sub SetAllTextBoxForeColor (clr As Long)

Dim ctl As Access.Control

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.ForeColor = clr
End If
Next

Set ctl = Nothing

End Sub


Nov 13 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Google Mike | last post by:
You know, while working on my moonlight corporation's LAMP project at home this weekend, I couldn't help but wonder if people writing similar projects are solving similar problems with having to...
8
by: Ilan | last post by:
Hi all I need to add data from two Excel sheets (both on the same workbook) to an existing table in my SQL DB. The problem is that each sheet holds different fields for the same record, though...
0
by: warlord | last post by:
In order to save typing, I've borrowed the text from a post of nearly 12 months ago.....but the problem still exists. I've been banging my head all day with this, so I'm hoping someone has some...
6
by: Brad | last post by:
I have an sql query that has specific criteria (like state='PA' or state = 'NJ'...) and would like to be able to have the user specify the criteria dynamically either through the web or from...
2
by: puunda | last post by:
Hi All, I had previously asked this question with regard to Cyrstal Reports, which I believe is not the most suitable for doing the job. The problem: I need to create a report with X number...
6
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new...
3
by: RC | last post by:
I can't quite grasp the concept of creating custom reports depending upon what options a user picks on a Form. For example, the user clicks on a "Print Reports" button and a Form pops up. On the...
9
by: cheryl | last post by:
I am relatively new to programming in Access for a multi user environment, and am having trouble figuring out if there is a way to accomplish one of our user requests. I am working on a multi...
5
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.