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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
63,408
Office Version
  1. 365
Platform
  1. Windows
Where exactly are you placing this code? In some event procedure?

Can you post your entire code exactly as you have it?
 

CT Witter

MrExcel MVP
Joined
Jul 7, 2002
Messages
1,212
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
 

lmhudson

Board Regular
Joined
Nov 14, 2007
Messages
106
Have sorted it (got my criteria the wrong way round so was always returning false), but thanks for the help anyway
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,669
Messages
5,838,684
Members
430,563
Latest member
Raeyven

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
Top