"Invisible" Control Unhides Itself on All Records

G

Guest

I created a control (cboProd_Testing) that is supposed to be invisible until
a specific value (2 for "Application Error") is selected in another combo box
on the form (cboCategory). When I go to a record and select Application
Error, the cboProd_Testing appears. The trouble is that it appears on all
records, not just those on which Application Error is selected.

Using info I found here, I put the following code in the After Update event
of cboCategory (see line 3) (the requery is for another combo):
Private Sub cboCategory_AfterUpdate()
cboDescription.Requery
'cboProd_Testing is visible when cboCategory = Application Error.
Me![cboProd_Testing].Visible = (Me.cboCategory = 2)
End Sub

Can anyone offer any suggestions for what to do?
 
W

Wayne Morgan

A couple of possible problems. 1) If the first combo box is unbound, then
moving from one record to the next won't change its value. You may need to
do some work in the form's Current event to reset things. 2) You have the
form in Continuous Form view. For this, instead of hiding/unhiding the
control you may want to use Conditional Formatting. In form design view,
right click the second combo box and choose Conditional Formatting. Set if
for Expression and type the expression

cboCategory = 2

Next, adjust the fore and back colors to make it appear that the control is
visible/invisible instead of actually changing the visible property of the
control. The problem is the control will still be there if the user clicks
in the correct place or if the control is in the tab order, so you'll also
need to enable/disable and lock/unlock the control in the form's Current
event so that when you are on a record that you should have access to the
second combo box you can, but it will be disabled and locked when you are on
a record that it shouldn't be visible.
 
A

AlCamp

Susan,
I take it you're referring to a single form... but the principle applies
to continuous also.
In addition to the code that hides/shows cboProd_testing on the
AfterUpdate event of ApplicationError...
use the OnCurrent event of the form to test for a 2 in ApplicationError,
and hide/show cboProd_Testing accordingly.
hth
Al Camp

Susan L said:
I created a control (cboProd_Testing) that is supposed to be invisible
until
a specific value (2 for "Application Error") is selected in another combo
box
on the form (cboCategory). When I go to a record and select Application
Error, the cboProd_Testing appears. The trouble is that it appears on all
records, not just those on which Application Error is selected.

Using info I found here, I put the following code in the After Update
event
of cboCategory (see line 3) (the requery is for another combo):
Private Sub cboCategory_AfterUpdate()
cboDescription.Requery
'cboProd_Testing is visible when cboCategory = Application Error.
Me![cboProd_Testing].Visible = (Me.cboCategory = 2)
End Sub

Can anyone offer any suggestions for what to do?
 
G

Guest

Al and Wayne: Thanks ever so much for your responses and advice. I decided to
try Al's suggestion first, and it worked like a charm. But I've put Wayne's
conditional formatting suggestion in my Access Tips database. I had not
thought of using conditional formatting that way. Creative!

Thanks so much again!

AlCamp said:
Susan,
I take it you're referring to a single form... but the principle applies
to continuous also.
In addition to the code that hides/shows cboProd_testing on the
AfterUpdate event of ApplicationError...
use the OnCurrent event of the form to test for a 2 in ApplicationError,
and hide/show cboProd_Testing accordingly.
hth
Al Camp

Susan L said:
I created a control (cboProd_Testing) that is supposed to be invisible
until
a specific value (2 for "Application Error") is selected in another combo
box
on the form (cboCategory). When I go to a record and select Application
Error, the cboProd_Testing appears. The trouble is that it appears on all
records, not just those on which Application Error is selected.

Using info I found here, I put the following code in the After Update
event
of cboCategory (see line 3) (the requery is for another combo):
Private Sub cboCategory_AfterUpdate()
cboDescription.Requery
'cboProd_Testing is visible when cboCategory = Application Error.
Me![cboProd_Testing].Visible = (Me.cboCategory = 2)
End Sub

Can anyone offer any suggestions for what to do?
 

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