|
-
Aug 8th, 2007, 02:17 PM
#1
Thread Starter
New Member
[Access 2003] Hiding a subform based off of a selection
Greetings everyone!
First off, I know very little about VBA. What I do know, I've copied modified it to work in my databases.
Ok, here's my problem that I can not figure out. I hope I can explain it right
1. I have a sub form that I want hidden unless it matches text in a field.
2. The field that I will be using is a Combo Box using a look up to a table. I have 5 different answers that could be selected. Let's call them :
Answer 1
Answer 2
Answer 3
Answer 4
Answer 5
So far this is what I have and it works fine. It hides the sub form unless Answer1 is selected.
Code:
Private Sub PersonnelType_AfterUpdate()
Dim ctl As Control
For Each ctl In Me.Controls
If Me.Controls(ctl.Name).Tag = "MyControllName" Then
Me.Controls(ctl.Name).Visible = False
End If
Next ctl
If Me!PersonnelType = "Answer 1" Then
For Each ctl In Me.Controls
If Me.Controls(ctl.Name).Tag = "MyControllName" Then
Me.Controls(ctl.Name).Visible = True
End If
Next ctl
End If
End Sub
However, what I need is the sub-form to be hidden unless Answer1 OR Answer 4 is selected. It will still remain hidden if Answer 2, 3, or 5 is selected but if Answer 1 OR Answer 4 (or more if I want) is selected, it will show the sub-form so I can enter data.
I've tried using Or but like I said, I really don't know VBA to figure out what will work.
Can anyone please lend a helping hand?
Thank you!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|