Modules & VBA :: Back Color On A Label
Jun 30, 2014on one of my forms I want the option to change the backcolor of a label and no matter what I try it wont work right.
Code:
Me.ColorlvlOne.BackColor = vbBlack
on one of my forms I want the option to change the backcolor of a label and no matter what I try it wont work right.
Code:
Me.ColorlvlOne.BackColor = vbBlack
Code:
'Pacer frame set to proper background
If Me.FrmPacer.Value = 1 Then
Me.LblPacer.BackColor = vbGreen
ElseIf Me.FrmPacer.Value = 2 Then
Me.LblPacer.BackColor = vbYellow
ElseIf Me.FrmPacer.Value = 3 Then
Me.LblPacer.BackColor = vbRed
[code]...
I have multiple frames on one subform that when selected sets a unassociated labels back color. Then when cancelled by undo code the back color stays on the color that it was changed to on afterupdate event from the frame with option controls. I would like to loop thru but could not come up with the proper method if it is even possible.the above code works after refreshed, but just wondering if there is a shorter or more efficient method.
I want to change the color of a label based on whether a checkbox is checked or not. Here is the code that I have right now that is not working.
If Not IsNull(MMS) Then
Label16.BackColor = 65535
End If
Can anyone help me out on this one?
learnasugo
How can I indicate with a color change in the label, that a checkbox is checked? I've got it working ...sort of. but when the change occurs it's happening gobally - I want the label to color to apply only to the record I'm viewing. If the check box is checked then the color should be red, otherwise black.
My code is as follows:
Active_Admission.Value = -1 Then
Label1177.ForeColor = vbRed
ElseIf Active_Admission.Value = 0 Then
Labe1177.ForeColor = vbBlack
Exit_Sub_Active_Admission_click:
Exit Sub
End If
End Sub
Also, the condition only works with -1 and 0 - I've read in other places that the condition is 1 and 0. HELP!
LSB
I have several forms that each has a dozen or more checkboxes, true/false. I want to be able to change the background color of the label of each checkbox depending on if the checkbox is true or false. I have used the following code which works great:
If Me.A = True Then
Me.lblA.BackColor = vbYellow
Me.lblA.BackStyle = 1
Me.lblA.ForeColor = vbRed
Else
Me.lblA.BackColor = vbWhite
Me.lblA.ForeColor = vbBlack
End If
Me.A refers to T/F checkbox A and Me.lblA refers to its label. This is repeated for each of the checkbox controls. If the control is [B], then its label is lblB. I have used this in the form OnCurrent event and the checkbox control OnUpdate event. I was wondering if I could use the tag property to this, saving me writing countless lines of code and having the OnCurrent event of each of the forms so long and cumbersome. And I do know that I can use conditional formatting to do this, but I would prefer not to use that method. Is there any way to do this using the tag property and not so many lines of code?
Using Access 2010. I have a form on which I've placed a simple label. I try to set the label border color to black but it shows grey. I can set the border color to #000000 and it's grey. I set it to #000001 and it shows black as expected.
I'm thinking it has something to do with the themes, but shouldn't an exact color code show as expected? As a new member (<10 posts) I can't post an actual link, but here's the text of the location: [URL] ....
Is it possible to use two color fonts on one label? I want to bring attention to the user that by clicking a certain button they can perform a search by "Name" and by clicking on the other button, they can perform a search by "Appointment".
I have a switchboard type form with some buttons. The two buttons in question are labeled, "Search for Appts by Name" and "Search for Appts by Appointment". I want to keep the "Search for" section of the button in black font, but change the "by Appointment" and "by Name" to red font.
Quick question here I hope.
I've got a little box covering up a drop down arrow on a combo control that resides on a tab control. The problem is that, since the Back Color property isn't available for a tab control, I have no idea what color it is...which is what the color of my box object (rectangle technically) needs to be so as to blend in. It looks a little garrish with it standing out there...
Any ideas what the default color of the tab page background is? Using Access 2003.
Thanks
-NR
Hi all,
Using Access 2003, WinXP SP2.
I have a form with the standard light grey background. I insert a tab control, and the default back color is white. I set the BackStyle to Transparent, and it still displays as white.
Am I missing something here, I want the back color of the tab control to be the same as my form.
Now, what's really odd, is in this project it creates tab controls as white, but if I open an old project of mine, it creates tab controls with the same light grey back ground of the form.
Any help?
TIA
Hammy
I have a CONTINUOUS form that shows all my records. I want it to change the back color of a field when it is a certain value. so far i get it to change back color when the very first record in the list is a certain value, but then it will change the back color for every value and not just one value.
can i fix this?
I would like the label for a text box to read "B&W or Color" for a database of photographs.
Access will not accept the ampersand. Since this is just a label, I thought I could get away with using this symbol.
Is there a way to get the label to accept the ampersand?
Is there a way to change the back color of an active field in a form? Meaning, when I tab through my form and the field I tab to becomes active, the field turns white. This poses a problem because my form back color is black and my field text is white. When the field is active, I can't see the value in the field due to the back color defaulting to white. Does this make sense? Is there a way to change it?
View 7 Replies View RelatedThis is re-statement for clarity of earlier thread deleted.
In Access 2010 I have a Report with a Detail Section that shows a record and a Sub-report that shows the many records of a one-to-many relationship.
The Report Detail Section Property Sheet specifies a Back Color and a different Alternate Back Color.
Report View alternates the Detail Section background colors correctly.
Print View and Printing DO NOT correctly alternate the background colors. Back color and Alternate Back Color appear in irregular sequences.
how to fix it?
Is it possible that once the command button "Send Cost Request" in red is pressed it will change to green?
View 3 Replies View RelatedI have images in my form, say, Image1 and Image2 . The default background color for all of them are white. If the user click image1, the background color has to be red. If the user click image2, the background has to change to red and the image1 retains its default color ( White ).
I have six images to loop through these. Image1 to image6.
I have a form in datasheet with the fields "Date In" and "Date out" among other.
I want to be able to Change the backcolour of the "Date In" to red, yellow, or green depending on the length of time elapsed between current date and date in. This works fine on the conditional formatting, but now I only want to apply this formatting IF the "Date Out" is empty.
Access 2007.
I'm using Access 2010
What I want to be able to do is to assign a back colour to a control from VBA. There are many colours and what I thought would be an easy process was to choose a suitable colour to be assigned using the colour picker for a control, note the hex number then in my vba code would be
if... then me.mycontrol.backcolor=&HF0AD34
This compiles OK, but produces a completely different colour - I'm expecting an orange colour but getting blue and in another example a pale blue is coming out a brown.
Research indicates adding an ampersand to the end changes the value from integer to long but if I type
if... then me.mycontrol.backcolor=&HF0AD34&
The second ampersand disappears. In the immediate window
?&HF0AD34
?&HF0AD34&
?Val("&HF0AD34")
?clng("&HF0AD34")
?Val("&HF0AD34&")
?clng("&HF0AD34&")
All produce the same value of 15772980, which if I copy back to the control backcolour property produces the blue colour and not the required orange - which if i debug.print me.mycontrol.backcolor give me 3452400 - the correct number for orange.
The problem seems to be converting the hex number to a long.
Also how to modify the properties window to show the decimal value rather than the hex value, but can't see anywhere to do this.
How do I conditionally change the Back Color and Alternate Back Color based on the value of notes.FollowUpDate? I have a continuous form using the following code:
Code:
Private Sub b_all_past_Click()
Me.resultsFrame.SourceObject = "FollowUp_bystaff"
Me.resultsFrame.Form.RecordSource = "SELECT * From notes WHERE (((Notes.FollowUpDate) < Date()+1) And ((Notes.followup_person_id) = GetCurrentUserId()))ORDER BY notes.priority,(notes.FollowUpDate) DESC;" '
End Sub
I have a form with about 100 labels and would like something to happen when I mouseover. So I have a following code:
Code:
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BackColor = vbBlue
End Sub
[Code]....
Is it possible to set any label id as query parameter in sql code or access?
View 5 Replies View RelatedI have a calendar to let the users pick up the days and will be save temporaly in a table to print but i only can display the current mouth in calendar, went the user change the mouth the color of the boxes change to normal,in attache i send the BD, In resume, the users select the days in calendar and went change from one mounth to another the days picked stay with color.URL...
View 7 Replies View RelatedI created a subform in side a form where I have some data. The idea is to fill in the row with a color if a value is met, like "Reset".Conditional format is working (for one field), but in Access 2003 I can only have 3, and I have like 6 values to choose from.I use the below code to no avail:
Code:
Option Compare Database
Private Sub Form_AfterUpdate()
If Me.Legend = "Reset" Then
Me.Legend.BackColor = vbRed
End If
End Sub
I am studying error handling. I am using VBA Developers Hand Book and some Google stuff. I have been over the material several times and cannot find my mistake. When I click cmdFindState it give me "compile error" " label not defined",and stops at:
Code:
"On Error GoTo Err_cmdFindState_Click"
Code:
Private Sub cmdFindState_Click()
On Error GoTo Err_cmdFindState_Click
DoCmd.OpenForm "frmChurchesAll"
DoCmd.ApplyFilter "qryFindState"
'-----------------------------------------
' 51 Vermont
'------------------------------------------
DoCmd.GoToControl "ComboState"
[Code] .....
In Access 2007, I'm using labels as buttons because they can be made pretty. Since labels can't have focus, the focus is not shifted from whatever textbox users are in on button press. The value in that textbox is not considered updated when the macro runs, and things get messy from there.
I had been using a setfocus between two textboxes to work around this, but that seems like a copout. I now have a simple form with just a textbox and a button, so this seems like a good time to learn the right way to do this.
I have the following module which displays the backcolor of a checkbox label if it is true or false
Private Sub FormatLabel(chk As Control)
With chk.Controls(0)
If chk Then
.BackColor = vbYellow
.BackStyle = 1
.ForeColor = vbRed
[Code] .....
Which works great! But I cannot figure out how to make it work in the control AfterUpdate Event. I tried using it in the current control's (checkbox) after update event
Dim itm As Control
If itm.ControlType = 106 Then FormatLabel itm
but nothing happens (no change, no error message).
I have tried creating a new module:
Public Sub CheckBoxFormat(chk As Control)
If chk = -1 Then
chk.BackColor = vbYellow
chk.BackStyle = 1
chk.ForeColor = vbRed
Else
chk.BackColor = vbWhite
chk.ForeColor = vbBlack
End If
End Sub
But when I try to call it in the AfterUpdate event for the particular checkbox
Private Sub CheckBoxA_AfterUpdate()
Dim itm As Control
If itm.ControlType = 106 Then
CheckBoxFormat itm
End Sub
I get the error message "Expected Variable or Procedure not module"
So, (1) is my module all wrong or (2) am I calling it incorrectly or (3) wrong on both items?
I have n horizontal labels named Label_1 to Label_n. I'd like to assign values to the label captions by using a loop.
Something like:
For i = 1 To n
Set Label_i.Caption = i
End
However, this doesn't work. Message "Object required".
Any suggestions?