Invisible/Hidden Combo Boxes?

G

Guest

I have a tracking form with 4 combo boxes. Combo1 and 2 are linked, the
option chosen in Combo1 drives the options displayed in Combo2. Combo3 and 4
are linked to each other in the same way. But I don't even need Combo boxes
3 and 4 unless option 3 in Combo box 1 is selected. Is it possible to hide
Combo boxes 3 and 4, until the right option is selected in Combo1? If so,
how? (please advise on necessary relationships between tables)

Thanks!
 
G

Guest

Why not just set the visible properties of combo 3 & 4 based on the selected
value in combo 1. i.e
Private Sub Combo1_AfterUpdate()
if me.combo1.value = "condition to show" then
me.combo3.visible = true
me.combo4.visible = true
else
me.combo3.visible = false
me.combo4.visible = false
end if
end sub

if you'd rather just have 3 & 4 greyed out (but still visible) use the
enabled property instead.

Hope that helps
 
G

Guest

Sounds good, but I must be doing something wrong. I put the code you gave in
the AfterUpdate event for Combo1, under the Requery that I use the make sure
the right values are showing in Combo2. I get an ambigious name detected
error. I put the name of the option in Combo1 in the "condition to show".
Is there something else I should do?
 
G

Guest

Private Sub ChangeMade_AfterUpdate()
Me.ChangeType = Null
Me.ChangeType.Requery
Me.ChangeType = Me.ChangeType.ItemData(0)
End Sub

Private Sub ChangeMade_AfterUpdate()
If Me.ChangeMade.Value = "Rules" Then
Me.Groups.Visible = True
Me.Names.Visible = True
Else
Me.Groups.Visible = False
Me.Names.Visible = False
End If
End Sub

Private Sub Groups_AfterUpdate()
Me.Names = Null
Me.Names.Requery
Me.Names = Me.Names.ItemData(0)
End Sub

Thanks for you help!
 
G

Guest

Whew... This is an easy one. As far as I know, you can't have more that one
of the same event - which is why you'd be getting an ambiguous error (meaning
you're calling one event which is in two possible and valid procedures and
Access doesn't know which one to go to). Just put the code I gave you in the
same Sub: i.e.

Private Sub ChangeMade_AfterUpdate()
Me.ChangeType = Null
Me.ChangeType.Requery
Me.ChangeType = Me.ChangeType.ItemData(0)

If Me.ChangeMade.Value = "Rules" Then
Me.Groups.Visible = True
Me.Names.Visible = True
Else
Me.Groups.Visible = False
Me.Names.Visible = False
End If
End Sub

Private Sub Groups_AfterUpdate()
Me.Names = Null
Me.Names.Requery
Me.Names = Me.Names.ItemData(0)
End Sub

Let me know if that fixes it.
 
M

Mark

You don't need the second AfterUpdate routine--that's what's causing the
ambiguous name error. Try this:

Private Sub ChangeMade_AfterUpdate()
Me.ChangeType = Null
Me.ChangeType.Requery
Me.ChangeType = Me.ChangeType.ItemData(0)
If Me.ChangeMade.Value = "Rules" Then
Me.Groups.Visible = True
Me.Names.Visible = True
Else
Me.Groups.Visible = False
Me.Names.Visible = False
End If
End Sub
 
G

Guest

Glad it was easy. (But don't get too comfortable!) I was wondering about
the 2 AfterUpdate events for the 1 combo box. I'm still very new to Access
and I wouldn't have thought to combine the subs. I did combine them and here
is what happens.

The form opens with Groups and Names visible.
When I select any of the options, Rules included, in ChangeMade, Groups and
Names dissappear, and don't reappear.

I decided to put the hide code in the AfterUpdate event of Combo2
(ChangeType) because the options are related and tied it to the option New
Rule. Got the same result. So I reversed the False and True and the form
opened with Groups and Names hidden. When I choose Rules in ChangeMade, the
first options to appear in ChangeType is New Rule, Groups and Names stay
hidden. When I go to the next option in the list Delete Rule, they appear!
I would like the form to open with Groups and Names hidden.

Keep the ideas coming, this is a great learning experience for me!
 
G

Guest

To have the boxes be invisible when your form opens, use the OnOpen() event
of your form and put in the code

me.groups.visible = false
me.names.visible = false

that way every time it is opened they will not be seen. Start with that and
we'll go from there.
 
G

Guest

Done! The form now opens with Groups and Names invisible. I jumped ahead a
bit, just to see if this would work. This is the code I put in the
AfterUpdate event of the ChangeMade combo box.

Private Sub ChangeMade_AfterUpdate()
Me.ChangeType = Null
Me.ChangeType.Requery
Me.ChangeType = Me.ChangeType.ItemData(0)
If Me.ChangeMade.Value = "Rules" Then
Me.Groups.Visible = True
Me.Names.Visible = True
End If
End Sub

When I chose Rules in ChangeMade, nothing happened. But we have the first
part of what I wanted to do accomplished, so I think that is a good start.
If you are running short on time, if you can direct me to a good resource on
this issue, I may be able to get this figured out on my own. I really do
appreciate your help and persistence..
 
G

Guest

Well, if I were you now, I'd put a break point in at the if statement just to
see what is happening and try to debug from there. That way you'd be able to
answer questions such as - what value does me.changemade.value actually have?
- is it case sensitive? I use this same idea in several forms for an app
that I am currently building and it works fine, so you'll have to get into
some debugging to see exactly what is happening.

One thought (which would also be answered in debugging): is the AfterUpdate
event that you have code for actually being called? To check go to the
properties menu of the combo control and open the events tab. In the
AfterUpdate event it should have "[Event Procedure]" beside it. Click there
to see the "..." beside it. Click on it. If it takes you to your code, then
at least that is set up right. If not, put your code in where it takes you.


As far as resources go, I don't know of too many; I usually just learn on
the fly (i.e. hack away until it works!) but you can try here (at lease for
Access 97)

www.microsoft.com/accessdev/articles/bapp97/toc.htm

Good Luck
 
G

Guest

Sorry if I wasn't clear. I didn't put the code on both AfterUpdates events,
only one at at time, just to see what would happen. I used the code below,
but Groups and Names don't appear when I choose Rules in ChangeMade.
Actually, Groups and Names dissappear as soon as I choose any option in
ChangeMade. (I tried this before I tried the code in the FormOpen event, as
suggested by Kabaka in the previous post.)
 
G

Guest

I've played with this in several different ways, one thing that did happen
consistently is that once Groups and Names are invisible, they don't
reappear. I have to pull the Property sheet and reset the Visible field to
Yes. The code is in place, the Requery works fine. The If-Then-Else routine
seems to work, just not how we thought.
 

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