Back fill color in textbox

HaChIrish

Registered User.
Local time
Yesterday, 22:45
Joined
Oct 11, 2002
Messages
28
Is there a way to change the background color of a textbox based on a yes/no answer? It's basically a checkbox, but I want to use a textbox instead that will fill black if true and stay transparent if false. Is it possible?
 
HaChIrish,

Put the following in the AfterUpdate of the
Checkbox:

Code:
If Me.YourCheckBox = True Then
   Me.YourTextBox.BackColor = 0 ' Black
Else
   Me.YourTextBox.BackColor = ! ' I don't know the value
End If

Wayne
 
How would I do this in a report? In the form I just use a checkbox, but when I print the report I want it to fill black in a textbox.
 
You need to put some code in the On Open event of the report. If blahblah is true then BackStyle=Normal (BackColor can just stay set to black). If blahblah is false then BackStyle=Transparent. I'm not sure what blahblah is because I don't completely understand your post.
 
blahblah was actually in another post I made, and that one was answered.

What I'm trying to do here is I have an application with about 20 yes/no checkboxes in a form. The report I print is based on the query that feeds both the form and the report. But instead of printing a checkbox on the report, I want to have a square TEXTBOX that fills black or transparent depending on the true/false value of the checkbox. The only reason I'm doing it this way is because the report is based on an existing paper report that I transposed to a report in Access. I'm currently using:

=iif([checkbox]=true,"X","")

on each textbox I have. Just wanted to know if it's possible to fill it black instead of with an X. Hope that helps.
 
In the On Format event of the Detail section (or whatever section you want the text boxes in), put this in, changing the [checkbox] and [textbox] to whatever you have.
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  If FormatCount = 1 Then
    If [checkbox] = True Then
      Me![textbox].BackStyle = 1
    Else
      Me![textbox].BackStyle = 0
    End If
  End If
End Sub
Just make sure you keep the BackColor set to black.
 

Users who are viewing this thread

Back
Top Bottom