Building Event Procedure help

tblues87

Registered User.
Local time
Today, 06:56
Joined
Apr 7, 2011
Messages
22
Hi
can someone please help me with this
I have a main form and a subform. In main form there is a check box.
What I need is that when the subform is opened to look in main form if the check box is true or false and then the control on subform is enabled=True or False

I wrote this

Code:
Private Sub Form_Load()
If [........] = True Then
[Broj rata].Enabled = True
Else
[Broj rata].Enabled = False
End If
End Sub

I don't know how to access the check box

Thanks
 
Since a subform loads Before the mainform a code in the load event will fail, but you you could perhaps use the OnCurrent event.

Code:
Private Sub Form_OnCurrent()
If Me.Parent.chkbox = True Then
     .....
End If
End Sub

But since you checkbox is a boolean you can refer to its status directly to change the enabled property.

Code:
Private Sub Form_OnCurrent()
[Broj rata].Enabled = Me.Parent.chkbox
End Sub

JR
 
Second option since you subform OnCurrent event only fires when it gets focus a better idea is to revers the prosess and use your Main forms OnCurrent and your checkbox's AfterUpdate event to enable/disable your control on your subform

Code:
Private Sub Form_OnCurrent()
Me.NameOfSubformConteiner.Form.[Broj rata].Enabled = Me.chkbox
End Sub

JR
 
Thanks but I figured it out, on main form where is the check box I added the after update event
Code:
Me!Subform1.Form!ControlName.Enabled
 

Users who are viewing this thread

Back
Top Bottom