How to keep greyed-out a combo box unless check box is checked!

eurojourney

Eurojourney
Local time
Today, 15:53
Joined
May 12, 2010
Messages
24
Hello everyone,

First of all, this is a great forum and have found some answer to my rather basic questions so thanks for the help already received. I am an Engineer so I am familiar with the logic behind programing and am quite computer literate; however, I am very new to Access and aren't that familiar with it.

I work in real estate with a big developer in Miami. I have two main forms feeding two main tables and several small tables feeding some combo boxes in those forms. The two main forms are for registering clients and brokers. The client's form has a check box that asks whether the client contacted my office with a broker or not. If checked, the answer is yes and ideally the Broker's combo box listing all the brokers will be enable at that point; otherwise, the combo box should be "greyed-out" and unable to be selected to avoid wrong data going into the table. This is very critical since I want to be sure someone that DID NOT come with a broker by mistake shows in the database that it did come with a random broker as a resilt of a mistake done by the person entering the information in the form, i.e. the receptionist.

Anyone can tell me how to go about having the combo box greyed-out at all times except when the check box is selected? I know this has to do with the events of the check box and perhaps the form as well, but the code and how and where to enter the code I am lost.

Thank you and sorry for a likely basic question - I am new to this software.

Jorge / eurojourney
 
On the AfterUpdate event of the checkbox, try ...

Code:
If Me.chkCheckBoxName = True Then
     Me.cboComboBoxName.Enable = True
Else
     Me.cboComboBoxName.Enable = False
End If

Then on the OnCurrent event of the form, use

Code:
Call Me.chkCheckBoxName_AfterUpdate
HTH,

-dK
 
You need to set the Triple State property of the checkbox to YES. Then it will work for setting it to NULL if you want the gray, False to have it unchecked and True to have it checked.
 
I tried this but it did not work. Also, what is the connection between the combo box with the names of the brokers in the client form and the check box - I don't see in the code anything that relate the two.

This is the code for the checkbox under the Afterevent event:

Private Sub Broker_Involved_AfterUpdate()
Call Me.Broker_Involved_AfterUpdate
End Sub

This is the code as told in the thread for the Form:
Private Sub Form_Current()
Call Me.Broker_Involved_AfterUpdate
End Sub

This is in the Current event of the Client Form. I also set the Triple state to Yes as instructed. Any clues?
 
What is the name of the checkbox. It looks like you have a circular reference going on here:
Private Sub Broker_Involved_AfterUpdate()
Call Me.Broker_Involved_AfterUpdate
End Sub

You have put the call to update the same afterupdate it is in.
 
Creating some .. well .. what appears to be some circular referencing.

You have ...

Private Sub Broker_Involved_AfterUpdate()
Call Me.Broker_Involved_AfterUpdate
End Sub

Try ...

Private Sub Broker_Involved_AfterUpdate()
If Me.Broker_Involved = True Then
Me.cboComboBoxName.Enable = True
Else
Me.cboComboBoxName.Enable = False
End If

Replace cboComboBoxName with the combo box name you want enable. Or if you want, you can use .Locked. I used enabled because that was the word thrown out there but there is a difference between enabled and locked.

-dK
 
Last edited:
This is the code I used:

Private Sub Broker_Involved_AfterUpdate()
If Me.Broker_Involved = True Then
Me.Broker_Involved.Enable = True
Else
Me.Broker_Involved.Enable = False
End If
End Sub
Private Sub Form_Current()
Call Me.Broker_Involved_AfterUpdate
End Sub

The name of the CheckBox is "Broker Involved" and the name of the form is "Client". There is no need to do anything with the combo box for the name of the Broker "Broker Name"?. Also, there are other combo boxes and text boxes in the form, none of this will affect them?
 
This is still wrong and a circular reference. You have code which states that if the checkbox is true then it should be enabled but if the checkbox is false then it isn't and it is in the after update of the checkbox. So, let's try it again:

Code:
Private Sub Broker_Involved_AfterUpdate()
If Me.Broker_Involved = True Then
Me.[COLOR="red"][B]YourCOMBOBoxNameHERE.[/B][/COLOR]Enable = True
Else
Me.[COLOR="Red"][B]YourCOMBOBoxNameHERE[/B][/COLOR]= False
End If
 
And the shortened version of it is:

Code:
Private Sub Broker_Involved_AfterUpdate()
   Me.YourCOMBOBoxNameHERE.Enable = Me.Broker_Involved
End Sub
 
Hello,

I am so sorry but this is not working for some reason. I think I am doing exactly what you are suggesting - this is what shows up in my VB screen:

Private Sub Broker_Involved_AfterUpdate()
If Me.Broker_Involved = True Then
Me.Broker_Name.Enable = True
Else
Me.Broker_Name.Enable = False
End If
End Sub
Private Sub Form_Current()
Call Me.Broker_Involved_AfterUpdate
End Sub


My Check box name is "Broker Involved" and the combo box is "Broker Name". What am I missing? Again thank you and sorry for the basic request.

Jorge
 
If you have spaces in the names (and I would not use them as they cause pain and suffering) it should work like this:

Code:
Private Sub Broker_Involved_AfterUpdate()

   If Me.[Broker Involved] = True Then
      Me.[Broker Name].Enable[B][COLOR="Red"]d [/COLOR][/B]= True
   Else
      Me.[Broker Name].Enable[COLOR="red"][B]d[/B][/COLOR] = False
   End If
End Sub

Private Sub Form_Current()
   Call Me.Broker_Involved_AfterUpdate
End Sub


EDIT: You were also missing a D for Enabled.
 
Ok, I am going to try this now! I did not know I needed the "d" - I copy pasted the stuff provided before...I'll let you know if it works and try to avoid spaces from now on...thank you for you patience...
 
Wow...it did not work...I copy and pasted exactly as you provided...I went to events on the form and clicked on the three-dotted bottom on the current event and pasted the code. One portion is on the current event of the form, the other on the After event location. I can't select the check botton now and I can click on the pull down menu for the brokers anyway...???!?!?!?!?!??!?!?!?!?!?

I'm frustrated!
 
Can you post your database (remember to delete any sensitive data)? I think we might be able to solve this quicker that way. Remember to run COMPACT AND REPAIR first and then ZIP the file. Also, include instructions on which form we are to look at.
 

Users who are viewing this thread

Back
Top Bottom