Make field not visible

lmhudson

Board Regular
Joined
Nov 14, 2007
Messages
106
I have a form that I want to hide one of the fields if certain criteria is not met, how can I do this plz

On my main form I have a field which shows a users "Level" (Number) and when they press the button to open the form I want one of the fields hiding if the level is say < 50

I'm comfortable with the if statement to get the true / false answer but how to then hide the field.
Field visible by default

If answer = true
?? me.[fieldinquestion].visible = false ??
?? me.[fieldinquestion].visible = true ??

Both seem to hide the field, what's wrong
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Where exactly are you placing this code? In some event procedure?

Can you post your entire code exactly as you have it?
 
Upvote 0
You will need to modify to something like:

Code:
If Me.txtAnswer = True Then
Me.fieldinquestion.Visible = True
Else
Me.fieldinquestion.Visible = False
End If

Also, I would set [fieldinquestion] visible properties to false (right-click, properties, then scroll to visible =no)

That way the field is normally "hidden" and won't be seen if something else goes wrong in your code.

HTH,
CT
 
Upvote 0
Have sorted it (got my criteria the wrong way round so was always returning false), but thanks for the help anyway
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,720
Members
448,986
Latest member
andreguerra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top