Enabling some Form Controls after selecting from a combobox

Ghaznavi

Registered User.
Local time
Today, 21:34
Joined
Jun 20, 2010
Messages
23
Hi,

I have combo box in a form. I want to enable (to highlight) some controls in the form after selecting any value from my combobox.

For example, There are three values in the combobox. And :
When I select value1, I want an unbound combobox1 to be enable (This combobox is synchronized with a bound combobox2). So when this unbound combo is enabled, its synchronized bound combo should also be enabled.
When I selct value 2, it should do the similar action on a different unbound combobx3 (which is synchronized with a combobox4).

Kindly advise...:)
 
The basic code for enabling a control on a form:

Code:
me.txtcontrol1.enable = True/False

You would prefix that with an if statement to determine which controls are enabled/disabled. If value1 equal this enable controls, else value2 equal this enable other control else value 3 equal this etc Maybe a better way of doing it but that may help you get going too.
 
The basic code for enabling a control on a form:

Code:
me.txtcontrol1.enable = True/False

You would prefix that with an if statement to determine which controls are enabled/disabled. If value1 equal this enable controls, else value2 equal this enable other control else value 3 equal this etc Maybe a better way of doing it but that may help you get going too.

It will be helpful if you include an example :)
 
The example in post 2 didn't help?

It is indeed helpful, but unfortunately I still dont know where I should put this code. I mean , should I put it as after update event or after click event?. I put it in after update event and it worked but if we again uncheck the first control (which is a check box in this example), it acts as per the code and change the visibility.In this scenario, the data entry operator can input data in both cases by mistake .How to avoid this?
I am writing the code here :
Private Sub chkProducts_AfterUpdate()
If Me.chkProducts = True Then
Me.cboWorkOrder.Visible = True
Me.cboPartMark.Visible = True
Me.cboCategories1.Visible = False
Me.cboItemDescription.Visible = False
Else
Me.cboWorkOrder.Visible = False
Me.cboPartMark.Visible = False
Me.cboCategories1.Visible = True
Me.cboItemDescription.Visible = True
End If
End Sub

I am sorry for my ignorance. Please suggest :)
 
Last edited:
If you copy and paste it into either and then try and update the control you will be able to see the behaviour and choose the best for you.

I think I would probably try the after update event - Pbaldy will know best.
 
If you copy and paste it into either and then try and update the control you will be able to see the behaviour and choose the best for you.

I think I would probably try the after update event - Pbaldy will know best.

I put it in after update event and it worked but if we again uncheck the first control (which is a check box in this example), it acts as per the code and change the visibility.In this scenario, the data entry operator can input data in both cases by mistake .How to avoid this?
I am writing the code here :
Private Sub chkProducts_AfterUpdate()
If Me.chkProducts = True Then
Me.cboWorkOrder.Visible = True
Me.cboPartMark.Visible = True
Me.cboCategories1.Visible = False
Me.cboItemDescription.Visible = False
Else
Me.cboWorkOrder.Visible = False
Me.cboPartMark.Visible = False
Me.cboCategories1.Visible = True
Me.cboItemDescription.Visible = True
End If
End Sub
 
The link addresses where:

You would put that code in the After Update event of the control you're testing, so that when you changed the value it would execute the code. You might also want the code in the Current event, which would fire when you change records.

Perhaps you want to clear out controls when hiding them?
 
The link addresses where:

You would put that code in the After Update event of the control you're testing, so that when you changed the value it would execute the code. You might also want the code in the Current event, which would fire when you change records.

Perhaps you want to clear out controls when hiding them?

Actually, I just want to avoid a situation where the data entry operator could select the data from both comboboxes (cboPartMark & cboItemDescription) by mistake, in one record. The control sources of these two comboboxes are two fields in one table. And if one is filled, other must be empty in a single row(record).

Is there a solution for this?
 
Then perhaps it should be one field? In any case, did you miss:

Perhaps you want to clear out controls when hiding them?

In other words:

Code:
Me.cboWorkOrder = ""   'or Null
Me.cboWorkOrder.Visible = False
 

Users who are viewing this thread

Back
Top Bottom