Open and close field based on input of another field

Certified

Board Regular
Joined
Jan 24, 2012
Messages
179
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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
820
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
179
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
820
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,101,948
Messages
5,483,839
Members
407,415
Latest member
Anton1999

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top