Conditional formatting: show only border

AlekseijDR

New member
Local time
Today, 12:42
Joined
Jan 19, 2024
Messages
10
Hi, I would like to get a result similar to the image attached.
I searched over and over and also asket ChatGPT and Gemini for a solution, to no avail.

Any suggestions on how to achieve that? (if possibile, of course!)

Thank you very much!
 

Attachments

  • Esempio.jpg
    Esempio.jpg
    168.4 KB · Views: 19
What exactly do you mean by "show only border?" You only want to see the border around a control based on conditional formatting? Can you be a little more specific?

From the screenshot it looks like you are trying to highlight certain rows by showing only a border around them, rather than shading the background. Access conditional formatting does not give you direct control over the border style of a control, only the fill color, font color, etc. If you need the effect of just a border, the usual workaround is to use a box control or an unbound rectangle and make it visible when the condition is met. Another approach is to set the back color and fore color the same so it looks like the control is blank, then rely on the border to stand out.

Access conditional formatting does not give you that kind of control over borders in a continuous form. You can change back color, fore color, and font styles, but not the border. If you want to highlight a row with only a border, you would need a workaround, like adding a box or rectangle control behind the fields and toggling its visibility or color based on your condition.
 
use a button (or any control that has a transparent property (not visible)) called for this example btnBorder. Put it behind your controls and size as required. Ensure you have set a border colour and width - this example uses rounded corners

In the detail section create a textbox called txtCurrent, set it's default to 0 and back and border properties to transparent. Set left and top to 0 and height and width to a very small value - try 1mm.It needs to be visible (just) to trigger the detail paint event

in the form current event put the following code - change nomPhrasePK to whatever is the name of your PK it does not need to be a visible control
Code:
Private Sub Form_Current()

    txtCurrent = nomPhrasePK
  
End Sub

in the detail on paint event put

Code:
Private Sub Detail_Paint()

    btnBorder.Transparent = Not (txtCurrent = nomPhrasePK)
  
End Sub

you should get this effect
1756839586589.png
 
Last edited:
I have a couple of example databases showing the idea explained in post #3:


 
Be aware clicking between controls onto the form will cause button (or whatever is used) to show up over other controls.
 
Be aware clicking between controls onto the form will cause button (or whatever is used) to show up over other controls.
if that is a possibility in the button got focus event, transfer the focus to a valid control or even txtCurrent
 
Actually, on second thought, I must have been hitting the button control itself, not the form background.
 
similar as above but using textbox. Open demoBorderPaintEvent form and see the instruction and VBA code behind the form.
there is another form, demoBorderConditionalFormatting, that uses Conditional Formatting.
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom