display form fields based on data entry

Posted on 2009-04-29
Last Modified: 2013-11-28
Objective: Create automated MS Access 2007 form that adjusts based on data entry.
We are trying to create a data entry form to store data and print reports on our clients. Not all people are married or have children, thus we want to form to adapt to each individual case.

Example Form:

Two fields to start with: Client_Name_Field Is_Married_Checkbox
If married, then display new field Spouse Name field and Children_checkbox
If children, then display field Child Name field and [additional_children_checkbox1
If additional children, display Child2 Name Field hide additional_children_checkbox1 and display additional_children_checkbox2
Question by:mobdog
    LVL 16

    Expert Comment

    by:Chuck Wood
    Set the Visible property of the fields you don't want displayed to No.
    As the fields are needed, set their Visible property to Yes (see snippet).

    If Is_Married_Checkbox = True Then
        SpouseName.Visible = True
        Children_checkbox.Visible = True
    End If

    Open in new window

    LVL 11

    Accepted Solution

    This would work.  To elaborate on cwood's response... you would use this by setting the AfterUpdate() event (see field properties) so the code behind the form looks like this:

    Private Sub Is_Married_Checkbox_AfterUpdate()
    If Is_Married_Checkbox = True Then
        SpouseName.Visible = True
        Children_checkbox.Visible = True
        SpouseName.Visible = False
        Children_checkbox.Visible = False
    End If
    End Sub

    This will tell your form to run that code when the Is_Married_Checkbox is updated/changed.  The code says that if the box is true... set the spouse name and children checkbox to visible.  You should have the default VISIBLE properties on those two fields set to NO.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now