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
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,914
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,370
Messages
5,595,770
Members
414,017
Latest member
surajks

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