Using VBA to change label formatting for yes/no control when No (1 Viewer)

Philocthetes

Has a great deal to learn
Local time
Today, 08:09
Joined
Dec 19, 2017
Messages
28
I'm running a large-scale book digitization project and most of our work will be destructive, cutting books to run them through sheet-feed scanners.

An unknown subset of those books are only-known copies that need to be kept intact and transferred to our Archives. My database design has a Yes/No field Archives_Copy_Present, and No values need to be very obvious on some forms.

The 'plain logic' I want to apply is:
If Archives_Copy_Present is No, then change the font color of ArchivesLabel to Red.
I've tried messing around with formatting code I got from recording in Excel. I've Dimmed variables as Label, and tried object names like Forms!Print_QC!ArchivesLabel with no luck so far. Please help me face-palm at the obviousness of what I'm missing.
 

Ranman256

Well-known member
Local time
Today, 11:09
Joined
Apr 9, 2015
Messages
4,337
if you are using a checkbox for the yes/no field,
you must know the LABEL name that the checkbox is attached to,
then set the color of the label.
Code:
if Archives_Copy_Present.value then
  lblArcCopyPresent.forecolor = vbBlack
else
  lblArcCopyPresent.forecolor = vbRed
endif

but if you are not using checkbox for the yes/no, but rather a text box (tho i dont know why)

Code:
if Archives_Copy_Present.value then
  txtBox.backcolor = vbWhite
else
  txtBox.backcolor = vbRed
endif
 

Mark_

Longboard on the internet
Local time
Today, 08:09
Joined
Sep 12, 2017
Messages
2,111
For myself, I would set the FORM's background color based on the checkbox, not a label's. THAT should get people's attention.
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:09
Joined
Jan 23, 2006
Messages
15,379
I agree with Mark --if it's important, then the more conspicuous the better.
 
Last edited:

Mark_

Longboard on the internet
Local time
Today, 08:09
Joined
Sep 12, 2017
Messages
2,111
Its not about being conspicuous... its about


G
E
T
T
I
N
G

A
T
T
E
N
T
I
O
N
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:09
Joined
May 7, 2009
Messages
19,245
What type of form do you have
 

MarkK

bit cruncher
Local time
Today, 08:09
Joined
Mar 17, 2004
Messages
8,181
I've tried messing around with formatting code I got from recording in Excel. I've Dimmed variables as Label, and tried object names like Forms!Print_QC!ArchivesLabel with no luck so far.
If you have code, and you haven't posted your code, then what you are missing is posting your code. How can we tell what your code is missing without looking at your code???
hth
Mark
 

Users who are viewing this thread

Top Bottom