Open and close field based on input of another field

Certified

Board Regular
Joined
Jan 24, 2012
Messages
178
Hello,

I have a Table with 11 fields.

The first field is a drop-down field with two options. Lets call them option A and option B.

The remaining 10 fields relates to either option A or option B, but not both.

For example, if option A is selected, then fields 2, 4, 8, and 10 would apply.

Is there a way I can deny the user to the other fields (3,5,7 and 9), when option A is selected?
 
Last edited:

Some videos you may like

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
797
Yes, use a form.
Users should not have tables/queries exposed to them directly.
They should access the data through forms.
 

Certified

Board Regular
Joined
Jan 24, 2012
Messages
178
Sorry, I was not clear.

Yes, this would be a form, but how would I code the fields. I am new to Access.
 

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
797
I would probably have the form with only the dropdown visible, then when changed as Joe4 has advised, you make the relevant controls visible.
You probably have not thought of this yet, but what happens when you move through existing records.?
You would need code in the Current event as well, so might be better to make a private sub in the form that does all this and then call it from AfterUpdate and Current events of the form.?

HTH
 

stumac

Active Member
Joined
Jul 16, 2010
Messages
471
Or you could use Conditional formatting, there is an option to enable/disable the control. This doesn't require any coding and works for new or existing records.

One caveat for both options is if your control is enabled, data is added and then the control is disabled you could have records that don't meet your business rule but have been allowed to enter data.
 

Watch MrExcel Video

Forum statistics

Threads
1,099,017
Messages
5,466,057
Members
406,462
Latest member
I10V3xl

This Week's Hot Topics

Top