Not used to using hex values this way, but nonetheless don't understand what the issue might be?
Code:If Not IsNull(Form.ActiveControl) Then Form.ActiveControl.BackColor = CLng("&FFFFFF") Else Form.ActiveControl.BackColor = CLng("&F8BABB") End If
Not used to using hex values this way, but nonetheless don't understand what the issue might be?
Code:If Not IsNull(Form.ActiveControl) Then Form.ActiveControl.BackColor = CLng("&FFFFFF") Else Form.ActiveControl.BackColor = CLng("&F8BABB") End If
This should work
.BackColor = &HF8BABB
That's what I started with, but got compiler error "Expected Expression"
Code:If Not IsNull(Form.ActiveControl) Then Form.ActiveControl.BackColor = &FFFFFF Else Form.ActiveControl.BackColor = &F8BABB End If
Why not just use Conditional Formatting?
This works, but I could not get the white to render using the hex
Code:Private Sub txtFactor_GotFocus() Me.txtFactor.BackColor = Val("&F8BABB") End Sub Private Sub txtFactor_LostFocus() Me.txtFactor.BackColor = vbWhite End Sub
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
Completely missed that. Like I said at the OP, not used to doing much with hex. (and that's coming from an old bit twiddle'r)You left out the H
If you want white, could use vbWhite.
&HF8BABB returns a light shade of bluish-grey. Is that what you expect?
Review
https://stackoverflow.com/questions/...-ms-access-vba
Access Colour (color) Codes - jhTuppeny Consulting
RGB function (Visual Basic for Applications) | Microsoft Learn
My attempt to interpret this info:
The &H value will not retain leading zeros so &H0000FF becomes &HFF - Red.
ID ColorName ColorCodeDec ColorCodeRGB ColorCodeHex HexGBR 1 Black 0 000,000,000 000000 &H0 2 Red 255 255,000,000 FF0000 &HFF 3 Green 65280 000,255,000 00FF00 &HFF0000 4 Yellow 65535 255,255,000 FFFF00 &HFF00FF 5 Blue 16711680 000,000,255 0000FF &HFF00 6 Magenta 16711935 255,000,255 FF00FF &HFFFF 7 Cyan 16776960 000,255,255 00FFFF &HFFFF00 8 White 16777215 255,255,255 FFFFFF &HFFFFFF
I cannot get &H code to work for yellow, green, blue, magenta.
Suggest you stick with RGB() function.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Good thinking, this code works nicely. Still think the simple conditional formatting solution Welshgasman suggested is best if I can find the correct expression.Code:If Not IsNull(Form.ActiveControl) Then Form.ActiveControl.BackColor = vbWhite Else Form.ActiveControl.BackColor = RGB(248, 186, 187) End If
I'd bet a dollar that you've been told that there is nothing that equals null, or would have read that by now. If I'm wrong, you'll have to come and get your money.
If sticking with the formatting tool I suspect you'd have to use "Expression Is" not "Field value is".
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Use Expression Is and this type of thing:
IsNull([txtReqDate])
Yes, my post was more-or-less one of the many silly things I tried. Your money is safethere is nothing that equals null
Have a happy Thanksgiving.
Both post #9 and Conditional Formatting solved the OP. The only downside the is with CF'g is that, in design mode, the TB's show the back color shading of those fields that are subject to special processing. I.e., in need of shading when null. (I realize I can add some additional CF'g when Not IsNull)
That was 6 weeks ago, but same to you anyway.Have a happy Thanksgiving.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.