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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
822
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
822
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,102,778
Messages
5,488,822
Members
407,658
Latest member
Arias610

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top