473,465 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Combobox: disable or grey out items in the list

27 New Member
Access 2010, I am trying to disable "Give back" if I select it from the combobox, but is not working now, before it was because I was using a List, but I am using a query now, any help will be appreciate it

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. If Me.LeavingGroupProfile.RowSource = "SELECT tbl_LeavingGroupProfile.LeavingGroupID, tbl_LeavingGroupProfile.LeavingGroupName " & _
  4.         "FROM tbl_LeavingGroupProfile " & _
  5.         "WHERE (((tbl_LeavingGroupProfile.LeavingGroupName) = 'Give Back' " & _
  6.         "ORDER BY tbl_LeavingGroupProfile.LeavingGroupName; " Then
  7.        Me.Reason_for_Leaving.Enabled = False
  8.     Else
  9.        Me.Reason_for_Leaving.Enabled = True
  10.     End If
  11.  
  12.  
Feb 7 '18 #1

✓ answered by twinnyfo

See Post #2 above.

A streamlined version is below:

Expand|Select|Wrap|Line Numbers
  1. Private Sub LeavingGroupProfile_AfterUpdate()
  2.  
  3.     Me.Reason_for_Leaving.Enabled = Not (Me.LeavingGroupProfile.Value = "Give Back")
  4.  
  5. End Sub
Again, unless we are missing something, this is as straightforward as can be. Please clarify.

10 4381
gnawoncents
214 New Member
ivonsurf,

I'm a little bit fuzzy on when you're trying to make the disable/enable happen and which object you are trying to do it to. Your code indicates Reason_for_Leaving is the field you want disabled/enabled, so I'm operating off that assumption. If you simply want to disable the field when a user selects "Give Back" from the combo box, the code below should do what you need. If, however, you are trying to have it disable when "Give Back" is even an option to select, that would be another matter.

Expand|Select|Wrap|Line Numbers
  1. Private Sub LeavingGroupProfile_AfterUpdate()
  2.  
  3. If Me.LeavingGroupProfile.Value = "Give Back" Then
  4.     Me.Reason_for_Leaving.Enabled = False
  5.   Else
  6.     Me.Reason_for_Leaving.Enabled = True
  7. End If
  8.  
  9. End Sub
  10.  
Feb 8 '18 #2
ivonsurf123
27 New Member
Hello,

That's the thing it does not work, before worked because the Give back was withing a list of options as a List in that combobox, but now is not longer a list, it is a source: query/Table, when I select Give back it does not go gray out anymore.
Feb 8 '18 #3
twinnyfo
3,653 Recognized Expert Moderator Specialist
ivonsurf123,

Like gnawoncents, I, too, am a bit confused as to what it is that you are trying to disable. If your code sets the Row Source based on a selection from a Combo Box, then there is really no reason to check the value of the Row Source--simply refer to the Combo Box itself, as recommended.

Are we missing some important details about what you are trying to do and how you are trying to do it?
Feb 8 '18 #4
ivonsurf123
27 New Member
I create a table call LeavingGroupProfile, I have a form named Position Fills, in that form I have a combo box with a items to select, one of them is "Give back", now the way I bring that list into the combo box is through a Table/Query Row Source type, what I want to do now is in that combo box from the Position fill form, every time that I select "Give Back" another combobox named Reason for Leaving, also with a list coming from a Table/Query Row source Type to go gray out as soon as I select "Give Back" from Leaving Group Combobox in the Position Fills form.
Feb 8 '18 #5
twinnyfo
3,653 Recognized Expert Moderator Specialist
See Post #2 above.

A streamlined version is below:

Expand|Select|Wrap|Line Numbers
  1. Private Sub LeavingGroupProfile_AfterUpdate()
  2.  
  3.     Me.Reason_for_Leaving.Enabled = Not (Me.LeavingGroupProfile.Value = "Give Back")
  4.  
  5. End Sub
Again, unless we are missing something, this is as straightforward as can be. Please clarify.
Feb 8 '18 #6
ivonsurf123
27 New Member
Thank you twinnyfo, It works perfectly!
Feb 8 '18 #7
PhilOfWalton
1,430 Recognized Expert Top Contributor
To the best of my knowledge it is not possible to simply create a coloured row Combo Box, but I vaguely remember downloading a sample DB some years ago. I will see if I can find it when I get onto my main computer tomorrow.

Phil
Feb 8 '18 #8
twinnyfo
3,653 Recognized Expert Moderator Specialist
Technically, speaking, Phil's initial response should be set to "Best Answer." I merely clarified/streamlined his response.

Phil, concerning the colored row combo box, I wonder if it is possible to create a subform that mimics a combo box? But, so as not to hijack this post, that would be another thread/article....
Feb 8 '18 #9
gnawoncents
214 New Member
twinnyfo,

Thanks for posting the streamlined example. I've never considered constructing a line that way, but it is cleaner and makes perfect sense. Good stuff!
Feb 8 '18 #10
twinnyfo
3,653 Recognized Expert Moderator Specialist
gnawoncents,

I can't take any credit for that one. It's a little trick taught me by NeoPa. Since I've learned it, it has been incredibly useful in countless ways.

So glad I could hepp!
Feb 8 '18 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: dmanhr | last post by:
Hi, I'm developing a control (derived from ComboBox) with permanent items (First, Previous, Next, Last). So, I'd like it's collection of items couldn't be changed neither in design time nor...
2
by: tottigang | last post by:
Hi, I have a tabstrip and I have some tabs in it. On the first page, all the tabs are enabled, I need to disbale part of the tabs at a specific point in the application and again enable them. I...
3
by: MervinJadhav | last post by:
How to disable combo items? Mervin Jadhav Software Developer Solutiioneyes Pvt Ltd (http://www.solutiioneyes.com) 203, Sai Chambers, 16 Mumbai-Pune Rd, Pune - 411 003 INDIA
4
by: Patrick Flaherty | last post by:
Hi, Experienced programmer but new to PHP. Moreover I'm to use PHP with Xoops on top (this adds object orientation?). I don't seem to find a xoops Usenet group? Whatever the case (and...
2
by: FaWiizio | last post by:
Is it possible to add an item to a combobox this way: ComboBox1.Items.Add("Cool!") AND assign to this new Item a unique index ? As in HTML <option value="1">Cool</option>
1
by: Rick Shaw | last post by:
Hi. I've struggling with the combobox databinding in C#. What I was trying to do was: - Hard code the items in the combobox's Items (collection) property. (ie. 'Mon', 'Tue', 'Wed', 'Thu',...
6
by: active | last post by:
I need a combobox where the items are typed as string - not object. And another where the items are from a class I generated. Can one make such comboboxes from System.Windows.Forms.ComboBox?...
3
by: sharperrr | last post by:
Access2000 Hi I have a combobox which displays a list of values dependent on another field. On the fields onchange event the rowsource of the combobox changes according to the value in the...
2
by: Claudia Fong | last post by:
Hi, I added a tabcontrol in a panel in my form. My tabcontrol have more than 3 pages.. each page contains textboxes, combobox, checkbox. I want to disable the items of each of the page of...
2
by: =?Utf-8?B?RHJEQkY=?= | last post by:
I understand that the Value put into a DataGridViewComboBoxCell has to be a member of the Items list or an exception is thrown. I also understand that you can override that exception by handling...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.