473,394 Members | 1,703 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,394 software developers and data experts.

change text box color in a report

I want to change the backcolor of textboxes in a report depending on their
value.
I messed with this for a few hours but I'm not savvy with the syntax for
getting at controls in a report.

can anyone suggest a direction.

For example the Textboxes would contain values like "8R", "8S", "10S",

the numbers would change depending on user input, but the letters are
restricted to about 8 different letters that mean different things. I want
to change the color based on the letter value.

Jul 6 '08 #1
4 8490
On Sun, 06 Jul 2008 05:46:04 GMT, "J Lagos" <ru*********@shaw.ca>
wrote:

Use Conditional Formatting. And make sure the BackStyle of your
control is not Transparent.

-Tom.

>I want to change the backcolor of textboxes in a report depending on their
value.
I messed with this for a few hours but I'm not savvy with the syntax for
getting at controls in a report.

can anyone suggest a direction.

For example the Textboxes would contain values like "8R", "8S", "10S",

the numbers would change depending on user input, but the letters are
restricted to about 8 different letters that mean different things. I want
to change the color based on the letter value.
Jul 6 '08 #2
I need more options than conditional formatting provides so I gave this a
go...and it still doesn't work

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim ctl As Control
Dim strV
For Each ctl In Me.Section(0).Controls
With ctl
If .Tag = "W" Then
strV = Right(ctl, 1)
Debug.Print ctl.Name
Debug.Print strV
Select Case strV
Case "R"
.BackColor = RGB(255, 224, 244) 'pale red
Case "L"
.BackColor = vbYellow
Case Else
.BackColor = vbRed
End Select
End If
End With
Next ctl
End Sub
"Tom van Stiphout" <no*************@cox.netwrote in message
news:6l********************************@4ax.com...
On Sun, 06 Jul 2008 05:46:04 GMT, "J Lagos" <ru*********@shaw.ca>
wrote:

Use Conditional Formatting. And make sure the BackStyle of your
control is not Transparent.

-Tom.

>>I want to change the backcolor of textboxes in a report depending on their
value.
I messed with this for a few hours but I'm not savvy with the syntax for
getting at controls in a report.

can anyone suggest a direction.

For example the Textboxes would contain values like "8R", "8S", "10S",

the numbers would change depending on user input, but the letters are
restricted to about 8 different letters that mean different things. I want
to change the color based on the letter value.
Jul 6 '08 #3
On Sun, 06 Jul 2008 17:00:39 GMT, "J Lagos" <ru*********@shaw.ca>
wrote:

I pasted your code in a report in the Northwind sample database and it
worked. One gotcha I just learned about: you have to open your report
in code (NOT switch from design view to preview) for the Detail_Format
event to occur:
For example in the immediate window enter:
DoCmd.OpenReport "myReport", acViewPreview

-Tom.

>I need more options than conditional formatting provides so I gave this a
go...and it still doesn't work

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim ctl As Control
Dim strV
For Each ctl In Me.Section(0).Controls
With ctl
If .Tag = "W" Then
strV = Right(ctl, 1)
Debug.Print ctl.Name
Debug.Print strV
Select Case strV
Case "R"
.BackColor = RGB(255, 224, 244) 'pale red
Case "L"
.BackColor = vbYellow
Case Else
.BackColor = vbRed
End Select
End If
End With
Next ctl
End Sub
"Tom van Stiphout" <no*************@cox.netwrote in message
news:6l********************************@4ax.com.. .
>On Sun, 06 Jul 2008 05:46:04 GMT, "J Lagos" <ru*********@shaw.ca>
wrote:

Use Conditional Formatting. And make sure the BackStyle of your
control is not Transparent.

-Tom.

>>>I want to change the backcolor of textboxes in a report depending on their
value.
I messed with this for a few hours but I'm not savvy with the syntax for
getting at controls in a report.

can anyone suggest a direction.

For example the Textboxes would contain values like "8R", "8S", "10S",

the numbers would change depending on user input, but the letters are
restricted to about 8 different letters that mean different things. I want
to change the color based on the letter value.
Jul 6 '08 #4
The issue is my fault. I had the conditional formatting set in the
textboxes...your reference to conditional formatting clued me in, and I
checked it and removed the conditional formatting and the code ran fine.
"Tom van Stiphout" <no*************@cox.netwrote in message
news:oj********************************@4ax.com...
On Sun, 06 Jul 2008 17:00:39 GMT, "J Lagos" <ru*********@shaw.ca>
wrote:

I pasted your code in a report in the Northwind sample database and it
worked. One gotcha I just learned about: you have to open your report
in code (NOT switch from design view to preview) for the Detail_Format
event to occur:
For example in the immediate window enter:
DoCmd.OpenReport "myReport", acViewPreview

-Tom.

>>I need more options than conditional formatting provides so I gave this a
go...and it still doesn't work

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim ctl As Control
Dim strV
For Each ctl In Me.Section(0).Controls
With ctl
If .Tag = "W" Then
strV = Right(ctl, 1)
Debug.Print ctl.Name
Debug.Print strV
Select Case strV
Case "R"
.BackColor = RGB(255, 224, 244) 'pale red
Case "L"
.BackColor = vbYellow
Case Else
.BackColor = vbRed
End Select
End If
End With
Next ctl
End Sub
"Tom van Stiphout" <no*************@cox.netwrote in message
news:6l********************************@4ax.com. ..
>>On Sun, 06 Jul 2008 05:46:04 GMT, "J Lagos" <ru*********@shaw.ca>
wrote:

Use Conditional Formatting. And make sure the BackStyle of your
control is not Transparent.

-Tom.
I want to change the backcolor of textboxes in a report depending on
their
value.
I messed with this for a few hours but I'm not savvy with the syntax for
getting at controls in a report.

can anyone suggest a direction.

For example the Textboxes would contain values like "8R", "8S", "10S",

the numbers would change depending on user input, but the letters are
restricted to about 8 different letters that mean different things. I
want
to change the color based on the letter value.
Jul 6 '08 #5

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

Similar topics

2
by: Dalan | last post by:
This seems a bit odd and probably I'm overlooking something, but have not been able to change a text field to a memo one. Of course, I made the change in the related Table setting, however the...
4
by: DerekM | last post by:
I have a database project that I created with several forms and reports. I would like to be able to declare a single title and be able to change the title on all the forms and reports by changing...
2
by: Xiphias | last post by:
Hi, Im trying to change the color of a text box on a report that im printing from a form. On the form I got a check box that has to tricker the color of that textbox on the printed report....
3
by: Not Me | last post by:
Hi, I have a report, viewable in continuous form. I don't want the size of the report to change (it should fit address labels on the printer), but in order to minimise the space between empty...
2
by: Michael Hager | last post by:
Hello all, I have a client that has a database that produces certificates using an access report. The certificate has a picture of the person on it. The pictures were stored by SSN number, and...
5
by: Steve | last post by:
I need a way to programatically change the width of a textbox to display all the data knowing the font, font size and number of characters. Does any oone know of a reference somewhere ot a way to...
1
by: ngpost1 | last post by:
I have a Crystal Reports.Net report being generated from my C# application. I would like to change the background color of the details section (not the text mind you) of the report on certain...
3
by: TomislaW | last post by:
I am sending word document with e-mail from asp.net 2.0 application. I read doc file like this:FileStream fs = System.IO.File.Open(docPath,FileMode.Open,FileAccess.Read,FileShare.Read); Then...
4
by: Henrootje | last post by:
I have a REPORT with in it a subFORM Now I have this label (lblMonth) that I want to change. How should I do this? What would be the proper event to do this? The lblMonth should contain the...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.