Solved Detail Back color change (1 Viewer)

mloucel

Member
Local time
Today, 02:02
Joined
Aug 5, 2020
Messages
149
Hello ALL

I have a form that checks records and I need to change the color of the background of the details section to rgb(255,0,0) [RED] if a VOID record is found, I've gone thru a lot of videos and help but it looks like I am alone.
This is my idea:

If the value of VOID=true
Then Change the color of the DetailSectionBackgroundColor to RED
else
Keep the color of the DetailSectionBackgroundColor with the original color [say light blue]
end if

is there a way to accomplish this with VBA?
 

bastanu

AWF VIP
Local time
Today, 02:02
Joined
Apr 13, 2010
Messages
1,402
If this is in a single form (not continuous or datasheet) you add your code to the Current Event of the form:
Code:
If Me.txtVoid=True Then
    me.Section(acdetail).BackColor=RBG(255,0,0)
Else
    me.Section(acdetail).BackColor=RBG(0,0,0)
End if
In a continuous form I suggest you use conditional formatting to change the background of the controls instead.

Cheers,
 

mloucel

Member
Local time
Today, 02:02
Joined
Aug 5, 2020
Messages
149
If this is in a single form (not continuous or datasheet) you add your code to the Current Event of the form:
Code:
If Me.txtVoid=True Then
    me.Section(acdetail).BackColor=RBG(255,0,0)
Else
    me.Section(acdetail).BackColor=RBG(0,0,0)
End if
In a continuous form I suggest you use conditional formatting to change the background of the controls instead.

Cheers,
COOL it worked, just minor change:

Code:
         If ("Charts.Void") = True Then
            
            'Change the detail color to RED [Thanks to bastanu]
            Me.Section(acDetail).BackColor = RGB(255, 0, 0)
            
            MsgBox "                 Chart " & ChartNumber & " was found in the database" _
            & vbCr & vbCr _
            & "But the record has been marked VOID, If you believe this " _
            & vbCr & "is an error then call your ADMIN so that the" _
            & vbCr _
            & "record " & ChartNumber & " can be recovered properly", _
            vbCritical + vbOKOnly, "VOIDED CHART FOUND... "
            
            'Change to the original color of the form [Thanks to bastanu]
            Me.Section(acDetail).BackColor = RGB(245, 245, 237)
        
        Else
            'Something else
        end if
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:02
Joined
May 7, 2009
Messages
19,234
RGB(255, 0, 0) is the same as vbRed:

Me.Detail.BackColor = vbRed
 

Users who are viewing this thread

Top Bottom