Conditional Visibility

Maleficent

Registered User.
Local time
Today, 08:38
Joined
Oct 25, 2016
Messages
21
I have a user form and want a label and text box to appear subject to the answer of a combo box

so if the answer selected in the combo box is "Other" a label and text box will appear for the user to add in additional information

i found code online but it isn't working:

Code:
Private Sub txtRootCause_AfterUpdate()
If Me.txtRootCause.Value = "Other" Then
Me.lblOther.Visible = True
Me.txtOther.Visible = True
Else
Me.lblOther.Visible = False
Me.txtOther.Visible = False
End If

End Sub

I've tried this "on current" and "change" events too but no luck

I have also tried setting the field's properties to both visible and not visible in the property settings

where am i going wrong?

Thanks
 
show the rowsource of your combo.

Private Sub txtRootCause_AfterUpdate()
Me.lblOther.Visible = (Me.txtRootCause.Text="Other")
Me.txtOther.Visible = (Me.txtRootCause.Text="Other")

End Sub
 
First...this kind of code needs to be in both the AfterUpdate event, as shown...and in the OnCurrent event.

Next...what kind of Form is this...Single, Continuous or Datasheet?

Lastly...if, as the last line of the above, you add

Msgbox Me.txtRootCause


what results do you get?

Linq ;0)>
 
You don't need to use .value in an afterupdate and add debug.print txtRootCause


And if the lable has been assigned to the text box you only need to hide the text box the assigned lable will also hide
 
thanks for the quick responses!

arnelgp - this isn't doing anything

missinglinq - still not working and no msgbox pops up - this is leading me to think i'm missing something really basic! also not sure if relevant but the full event list is not showing - so "On Current" isn't showing as an option in either layout or design view (it was earlier..) does this shed any light? its a single form

MickJav - i've tried removing the .value , i'm not sure where to add the debug line? thanks for the tip about the label!
 
i'm wondering if its my macro settings.. the macro security settings are greyed out. but then i have other working macros...?

UPDATE - the macros that were working on friday have now stopped working!?
 
close your db.
re-open it it will show a warning, click to allow.
 
Gasman - this gives me a message "The macros in this project are disabled...."

so i think my last post is correct, but i can't change the settings as they are greyed out. i'm guessing this has been set by our IT dept but something has changed since friday! i'll enquire with them... thanks
 
...i'm guessing this has been set by our IT dept but something has changed since friday! i'll enquire with them...
I'd follow up on that! IT departments have a habit of 'updating' systems over the weekend when usage is lower/non-existent.

Does any code run?

Linq ;0)>
 
i found code online but it isn't working
Is there a mushroom shaped cloud over your office? Telling us it "isn't working" isn't very helpful.

Based on the last couple of comments, open the back stage and go to Access Options/Security and check the macro settings.
 

Users who are viewing this thread

Back
Top Bottom