View Single Post
  #6  
Old April 3rd, 2008, 02:32 AM posted to microsoft.public.access.forms
Allen Browne
external usenet poster
 
Posts: 11,706
Default Changing BackColor Property of Main Form Label from SubForm

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

???