Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visible Property and Option Groups

Status
Not open for further replies.

xhat

Technical User
May 18, 2009
25
US
Hi. I have an option group, and based on the option chosen in the group, I want certain labels and textboxes to have their visible property set to True (the default on the form is False). So I wrote the code below:

Code:
Private Sub Frame13_AfterUpdate()
    If Me.Frame13.Value = 4 Then
        Me.lblBuyIn.Visible = True
    End If
    
End Sub

No love. Clicking on the appropriate option button whose value is 4 does not set the label's visible property to True on the form. Rather, I should say that clicking on the option button does not make the label appear on the form as it should. I don't get any error messages, and the label does not appear after moving focus away from the option button, either (I know that is not how AfterUpdate works, but I tried anyway just to see if anything would happen...). Please help me stop scratching my butt on this one. Thanks.

"There is no spoon..." - anonymouse enlightened child
 
I do not see a problem, double check that you have [EventProcedure] in the event. The event may not be firing. The first thing I do when it does not look like a sub routine is executing, is to verify by putting in a message box.

Private Sub Frame13_AfterUpdate()
msgbox "in event afterupdate"
If Me.Frame13.Value = 4 Then
Me.lblBuyIn.Visible = True
End If
End Sub

Now you can first determine that it is taking place.

If you want it to toggle from visible to invisible based on the selection, you can write it as

Private Sub Frame13_AfterUpdate()
Me.lblBuyIn.Visible = (Frame13.Value = 4)
End Sub
 
MajP,

Thanks for the reply and the debugging suggestion. The msgbox did, indeed, fire ("Event fired."), however the control did not become visible on the form. A little more info on this problem:

For aesthetics sake, controls are overlapping each other, both made not visible at form load. Only the appropriate control is turned visible based on choices made in the Option Groups. Could it be a hidden control is somehow "hiding" the visible one underneath?

The choice is made during a new record entry. Should not affect the firing of the event, but thought it might be worth mentioning.

The Option Group is tied to an underlying field in a table, which itself is a lookup field to another table. The option value of the particular button I'm using to test my code is 4. My event procedure uses 4, but could the lookup field be a wrinkle in the proper evaluation of the code? I am going to put the msgbox in an If statement, and that should tell me if the option value issue is being handled properly.

thanks.




"There is no spoon..." - anonymouse enlightened child
 
Ok, interesting development. Apparently, Access doesn't like you to make a textbox's label visible without also making the textbox visible as well. Who knew?

Thanks for the debugging tip. It got me thinking in the right direction.



"There is no spoon..." - anonymouse enlightened child
 
I did not know that either. If the text box is visible you can make the label invisible, but you can not make the label visible if its textbox is invisible.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top