Subform code doesn't work (1 Viewer)

aman

Registered User.
Local time
Today, 11:13
Joined
Oct 16, 2008
Messages
1,250
I have a form and within that there is a subform. In the subform there is a frame named fraBreach with 2 option buttons(yes ,No).

Now I have written the code in the subform as below:

Code:
 Private Sub fraBreach_AfterUpdate()
If fraBreach.Value = 1 Then
cmdBreach.Visible = True
Else
MsgBox "hellO"
End If
End Sub

But when I load the form , and within that I go to subform and tick Yes for fraBreach then it doesn't do anything. It doesn't display cmdBreach.

Any help will be much appreciated.

Thanks
 

Tieval

Still Clueless
Local time
Today, 19:13
Joined
Jun 26, 2015
Messages
475
Code:
Private Sub fraBreach_AfterUpdate()
If me.fraBreach.Value = 1 Then
me.cmdBreach.Visible = True
Else
MsgBox "hellO"
End If
End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 19:13
Joined
Feb 19, 2013
Messages
16,609
1. if you look at the fraBreach properties - does it s [Event Procedure] next to the after update event property? If not, add it

2. where is the cmdBreach control? on the subform or the main form? If the latter, try Parent.cmdBreach.visible=True
 

Minty

AWF VIP
Local time
Today, 19:13
Joined
Jul 26, 2013
Messages
10,368
Try referring to the control, and please don't use the .Value property. It is unnecessary and causes problems with certain type of controls. Value is the default property. I wish I knew what web site or code example has encouraged the use of it.... Grrrr

If Me.fraBreach = 1 Then ...
 

aman

Registered User.
Local time
Today, 11:13
Joined
Oct 16, 2008
Messages
1,250
Thanks guys. It worked. Just had to add me in the front. Many Thanks.
 

Users who are viewing this thread

Top Bottom