[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

display form fields based on data entry

Posted on 2009-04-29
2
Medium Priority
?
634 Views
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
0
Comment
Question by:mobdog
2 Comments
 
LVL 16

Expert Comment

by:Chuck Wood
ID: 24262297
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
    Me.Repaint
    DoEvents
End If

Open in new window

0
 
LVL 11

Accepted Solution

by:
SeanStrickland earned 1500 total points
ID: 24262357
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
    Me.Repaint
    DoEvents
Else
    SpouseName.Visible = False
    Children_checkbox.Visible = False
    Me.Repaint
    DoEvents
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.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

872 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