Make combo box visible based on other combo box

B

Ben Pelech

Hello,

I am trying to hide a combo box on the form based on the selection of
another combo box. Below is the code I am using. It does not seem to be
working. Any help would be greatly appreciated.

Thanks

Private Sub Type_of_Contact_AfterUpdate()
If Type_of_Contact.Value = 8 Then
TransferredTo.Visible = True
Else
TransferredTo.Visible = False
End If
End Sub
 
J

Jeff Boyce

Ben

"... does not seem to be working" doesn't give us much to go on.

Does this mean that the field [TransferredTo] is visible all the time? None
of the time?

Does this mean you get an error message? ... saying what?

Does this mean Access shuts down? Your monitor dies? Your PC explodes?

More info, please ... <g>

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
B

Ben Pelech

Nothing is happening. The field is always there and wont disappear based on
the selection

Thanks

Jeff Boyce said:
Ben

"... does not seem to be working" doesn't give us much to go on.

Does this mean that the field [TransferredTo] is visible all the time? None
of the time?

Does this mean you get an error message? ... saying what?

Does this mean Access shuts down? Your monitor dies? Your PC explodes?

More info, please ... <g>

Regards

Jeff Boyce
Microsoft Office/Access MVP

Ben Pelech said:
Hello,

I am trying to hide a combo box on the form based on the selection of
another combo box. Below is the code I am using. It does not seem to be
working. Any help would be greatly appreciated.

Thanks

Private Sub Type_of_Contact_AfterUpdate()
If Type_of_Contact.Value = 8 Then
TransferredTo.Visible = True
Else
TransferredTo.Visible = False
End If
End Sub
 
K

Ken Sheridan

Are you sure that the numeric value 8 is the value of the Type_of_Contact
control's bound column? If the column in the control's RowSource which
contains the 8 is the first column then the BoundColumn property of the
control should be 1.

You can easily check the value of the combo box by temporarily adding a text
box to the form, with a ControlSource property of;

=[Type_of_Contact]

Or you can set a break point in the code and examine the value of the
control's Value property as you step into the code.

BTW once you've sorted the problem out you can do it in a single line:

Me.TransferredTo.Visible = (Me.Type_of_Contact = 8)

If the form is a bound one you'll probably want the same code in its Current
event procedure.

Ken Sheridan
Stafford, England
 
B

Ben Pelech

Works perfectly.

Thank you very much!!!

Ken Sheridan said:
Are you sure that the numeric value 8 is the value of the Type_of_Contact
control's bound column? If the column in the control's RowSource which
contains the 8 is the first column then the BoundColumn property of the
control should be 1.

You can easily check the value of the combo box by temporarily adding a text
box to the form, with a ControlSource property of;

=[Type_of_Contact]

Or you can set a break point in the code and examine the value of the
control's Value property as you step into the code.

BTW once you've sorted the problem out you can do it in a single line:

Me.TransferredTo.Visible = (Me.Type_of_Contact = 8)

If the form is a bound one you'll probably want the same code in its Current
event procedure.

Ken Sheridan
Stafford, England

Ben Pelech said:
Hello,

I am trying to hide a combo box on the form based on the selection of
another combo box. Below is the code I am using. It does not seem to be
working. Any help would be greatly appreciated.

Thanks

Private Sub Type_of_Contact_AfterUpdate()
If Type_of_Contact.Value = 8 Then
TransferredTo.Visible = True
Else
TransferredTo.Visible = False
End If
End Sub
 

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