Conditional control visibility on forms

A

Al Williams

Access 2003: I’m doing a database for a Learning Center. I have a
Household information form on one tab control and a Household Members
subform. The subform Default View is continuous and I have the current
record and a portion of the next record (Household Member) showing on
the subform.

I’d like to change the visibility of controls on the subform depending
upon combo box choices made by the user. But making a choice on one
record changes the controls on the subform showing the next record also.
Is there a way to keep control visibility changes on a form limited to
just the current record? I believe that I could change the subform
Default View to single and thereby mask the fact that the controls are
changing but I’d rather not. The event procedure I used follows:

Thanks.

Al Williams


Private Sub MemberRoleID_AfterUpdate()
' Make visible only those controls which are applicable to the
Household Member's role
'
Dim strRoleC As String
Dim strRoleD As String
Dim strRoleN As String
Dim strRoleP As String
'
strRoleC = "Caregiver"
strRoleD = "Dependent"
strRoleN = "N/A"
strRoleP = "Parent"
'
'If Caregiver selected
If Me!MemberRoleID = strRoleC Then
Me!lblStudentRole.Visible = False
Me!StudentRoleID.Visible = False
Me!lblStudentGrade.Visible = False
Me!StudentGradeID.Visible = False
Me!lblChildsBirthOrder.Visible = False
Me!ChildsBirthOrder.Visible = False
Me!lblParentStatus.Visible = False
Me!ParentStatusID.Visible = False
End If
'If Dependent selected
If Me!MemberRoleID = strRoleD Then
Me!lblStudentRole.Visible = True
Me!StudentRoleID.Visible = True
Me!lblStudentGrade.Visible = True
Me!StudentGradeID.Visible = True
Me!lblChildsBirthOrder.Visible = True
Me!ChildsBirthOrder.Visible = True
Me!lblParentStatus.Visible = False
Me!ParentStatusID.Visible = False
End If
'If N/A selected
If Me!MemberRoleID = strRoleN Then
Me!lblStudentRole.Visible = False
Me!StudentRoleID.Visible = False
Me!lblStudentGrade.Visible = False
Me!StudentGradeID.Visible = False
Me!lblChildsBirthOrder.Visible = False
Me!ChildsBirthOrder.Visible = False
Me!lblParentStatus.Visible = False
Me!ParentStatusID.Visible = False
End If
'If Parent selected
If Me!MemberRoleID = strRoleP Then
Me!lblStudentRole.Visible = False
Me!StudentRoleID.Visible = False
Me!lblStudentGrade.Visible = False
Me!StudentGradeID.Visible = False
Me!lblChildsBirthOrder.Visible = False
Me!ChildsBirthOrder.Visible = False
Me!lblParentStatus.Visible = True
Me!ParentStatusID.Visible = True
End If

End Sub
 
B

Brian

This is a perennial problem with Continuous view. When you enable/disable
controls, you are doing it per form, not per record. You can do some things
with Conditional Formatting, but these do not involve visibility per se
(except perhaps by placing white text inside a white box, which still leaves
the box enabled, even though the user cannot see its contents).
 
A

Al Williams

Brian,

Thank you for responding. It certainly wasn't obvious to me how to do
it, but I'm still very new at this. So, I was hopeful it could be done
because it would have been a very nice UI feature for the user. I'll do
something else. Thanks.

Al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top