Yes, thanks lots, this works on the main form, but I wanted to show you the
current state of the VBA in that sub-form because it doesn't work quite as I
would've thought it could. You may be able to suss out the cunundrum by
perusing it (see below)
Option Compare Database
Option Explicit
Private Sub Aneurism_AfterUpdate()
Call Form_Current
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[Aneurism] = Nz(DMax("[Aneurism]", "qry_Aneurism_JPS", "ID=" _
& Me.ID), 0) + 1
End Sub
Private Sub Form_Current()
Dim lngColor As Long
If Me.Aneurism 4 Then
lngColor = vbRed
Else
lngColor = vbWhite
End If
With Me.Parent!Label113
If .BackColor lngColor Then
.BackColor = lngColor
End If
End With
End Sub
Private Sub Form_AfterUpdate()
Call Form_Current
End Sub
I think you'll probably agree that there's a need for a modification or two
or three.
Thanks in any event - it's an improvement.
"Allen Browne" wrote:
If you expect this to change color in the main form as you move record in
the subform, you would need to use the subform's Current event, as well as
the AfterUpdate event of the *form* (not control.) Example below.
Private Sub Form_Current()
Dim lngColor As Long
If Me.Aneurism 4 Then
lngColor = vbRed
Else
lngColor = vbWhite
End If
With Me.Parent!Label113
If .BackColor lngColor Then
.BackColor = lngColor
End If
End With
End Sub
Private Sub Form_AfterUpdate()
Call Form_Current()
End Sub
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Access User" wrote in message
...
My main form is called "MRA Form_JPS" and has a child sub-form called
"subfrm_Aneurism". When the value of a control on the subform called
"Aneurism" reaches more than 4, I want the backcolor of a label called
"Label113" on the main form to go vbred, so I coded the following thinking
I
had it
Private Sub Aneurism_AfterUpdate()
If Me.Aneurism 4 Then
Me.[MRA Form_JPS]!Label113.BackColor = vbRed
Else
Me.[MRA Form_JPS]!Label113.BackColor = vbWhite
End If
End Sub
but it doesn't work yet.
Is there something goofy about the way the above's wrote, or does it have
to
do with the fact that Aneurism gets its values automatically from this VBA
code below:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[Aneurism] = Nz(DMax("[Aneurism]", "qry_Aneurism_JPS", "ID=" _
& Me.ID), 0) + 1
End Sub
???