Results 1 to 6 of 6

Thread: Open and close field based on input of another field
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Jan 2012
    Posts
    177
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Open and close field based on input of another field

    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 by Certified; Apr 25th, 2019 at 05:01 PM. Reason: spelling

  2. #2
    Board Regular
    Join Date
    May 2013
    Posts
    605
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Open and close field based on input of another field

    Yes, use a form.
    Users should not have tables/queries exposed to them directly.
    They should access the data through forms.
    Office 2007
    Access novice. Sometimes trying to give something back

  3. #3
    Board Regular
    Join Date
    Jan 2012
    Posts
    177
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Open and close field based on input of another field

    Sorry, I was not clear.

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

  4. #4
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    49,667
    Post Thanks / Like
    Mentioned
    51 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Open and close field based on input of another field

    You would use "AfterUpdate" VBA code, so that after that first field is updated, it disables certain of the other fields.
    See here: https://bytes.com/topic/access/answe...in-fields-form
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  5. #5
    Board Regular
    Join Date
    May 2013
    Posts
    605
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Open and close field based on input of another field

    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
    Office 2007
    Access novice. Sometimes trying to give something back

  6. #6
    Board Regular
    Join Date
    Jul 2010
    Posts
    401
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Open and close field based on input of another field

    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.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •