423,822 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,822 IT Pros & Developers. It's quick & easy.

Gray out combo box base on value list

P: 27

I just can't figure out how to grey out the combobox when value chosen is "closed". combobox is set to have a value list in the resource type and the resource is "Open", "Closed"

Expand|Select|Wrap|Line Numbers
  1. If Me.[Position_Status] = "Closed" Then
  2.     Me.[Position_Status].Enabled = False
  3.   Else
  4.     Me.[Position_Status].Enabled = True
  5. End If
May 14 '18 #1
Share this Question
Share on Google+
4 Replies

Expert Mod 15k+
P: 31,117
I would simplify the code :
Expand|Select|Wrap|Line Numbers
  1. With Me
  2.     .Position_Status.Enabled = (.Position_Status.Value <> "Closed")
  3. End With
Not forgetting that the code should be in both the form's Current event handler and the control's AfterUpdate event handler. Sensibly, it should be within a procedure that's called from within both event handlers.
May 14 '18 #2

P: 27
Thank you NeoPa, but did not work...The one I submitted does it, but it does not stay gray out(Disabled), it just flash it and go back to showing the field with value enable again when I change to another record. Thank you for helping.
May 15 '18 #3

P: 27
I was able to do it with a conditional formatting instead, it worked perfectly, thank you NeoPa

In Form Design View:
  • Right-Click on the Combobox
  • Click on Conditional Formatting
  • Under 'Condition1' select Expression Is
  • In the next box, enter [Position Status] = "Closed"
  • Now click on the 'Enabled' icon...the one on the far right (to turn the Enabled property off)
  • Click on OK
May 15 '18 #4

Expert Mod 15k+
P: 31,117
Thank you NeoPa, but did not work...
If it didn't work then I don't understand what you want ... or you haven't correctly implemented the suggestion.

Bear in mind that enabling a Control is only necessary for the current record. If you're using continuous form view (which would be new to this dicussion) then you certainly won't see each record set correctly. However, you will find you can only make the changes at the appropriate points.

If you are working with continuous forms then Conditional Formatting is probably a better solution.
May 15 '18 #5

Post your reply

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