Color queries in Form (1 Viewer)

chrisjames25

Registered User.
Local time
Today, 15:55
Joined
Dec 1, 2014
Messages
401
HI

Week ago PBaldy and Gasman helped me adapt an allen brown code to change back color of textboxes as i tab through them.

Works like a charm. Question is the code references the colour liek this

Code:
Private Const mlngcFocusBackColor = &HB0FFFF

I know how to change colours using rgb(,,,) but no clue how to find a colour i like and then write it like this. Any help explaining this would be great.

Cheers
 

MarkK

bit cruncher
Local time
Today, 07:55
Joined
Mar 17, 2004
Messages
8,180
Here's what I do. There is probably a faster way.
  1. Create a new Form1.
  2. Add a new textbox Text0.
  3. Still in design view, open the property sheet for Text0 and find the BackColor property on the Format tab.
  4. Click on the ellipsis (...) at the far right of BackColor property row, which opens a fancy color palette selector tool.
  5. Pick a color. This now becomes the background color of the control. In later versions of Access, however, this is no longer the actual long integer code. Maybe you get a reversed hex notation (#BBGGRR), or a text description like "Background 1, Darker 35%"
  6. To get the actual number, write code like...
    Code:
    Private Sub Text0_DblClick(Cancel As Integer)
        Debug.Print Me.Text0.BackColor
    End Sub
    ...which writes the actual value to the immediate pane. See how that works?
  7. Copy that number to your constant...
    Code:
    Private Const mlngcFocusBackColor = 11599871
  8. Circuitous, but, done! :)
hth
Mark
 

Mark_

Longboard on the internet
Local time
Today, 07:55
Joined
Sep 12, 2017
Messages
2,111
Possibly a little easier way to accomplish the same;
Create a new blank form.
Add 4 Text boxes to it (TxtR, TxtG, TxtB, TxtCV).
In the after accept for each of the fields, add the following:

Code:
    Me.Detail.BackColor = RGB(TxtR, TxtG, TxtB)
    Me.TxtCV = "Colour Value = " & Me.Detail.BackColor

As you change values, your TxtCV will update to show the current value. Nice part is you can see the rest of the screen clearly to see just what colour it changes to. Toss on other fields / captions as needed to see how they will look on the background.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 00:55
Joined
Jan 20, 2009
Messages
12,851
This little open source freeware program called WhatColor shows a tool tip with the RGB values of the pixel under the cursor.

It is one of dozens of simple utilities written using the AutoHotKey scripting language.
 

isladogs

MVP / VIP
Local time
Today, 15:55
Joined
Jan 14, 2017
Messages
18,211
I use a modified version of a colour converter utility by Daniel Pineault which is available here: https://www.devhut.net/2010/11/17/ms-access-sample-colors/



EDIT: The latest versionof my utility is available at:
 

Attachments

  • ColourConverter.PNG
    ColourConverter.PNG
    19.2 KB · Views: 404
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:55
Joined
May 7, 2009
Messages
19,230
Something to play with color.
 

Attachments

  • aaWebSafeColor.zip
    43 KB · Views: 73

Users who are viewing this thread

Top Bottom