Results 1 to 4 of 4
  1. #1
    Gary Childress is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    34

    Grey out a combo box based on a date range in another combo box

    Hi,



    I'm trying to make a combo box grey itself out if a date in another combo box is between two particular months of the year. So for instance if the date chosen in the drop down menu of Combobox1 is between March 1st and June 30th, then I want Combobox2 to grey itself out. I've tried this using conditional formatting and for some reason can't get it to work.

    This is the expression I first tried to use in a conditional formatting rule for Combobox2:

    ([combobox1].value>3/1/14) and ([combobox1].value<6/30/2014)

    For some reason this doesn't seem to be working the way I want it to. When I pick a date that should grey out Combobox2 it doesn't grey it out. I've also tried the rule below and it doesn't seem to work either:

    ([Combo262] Between 3/1/2014 And 6/30/2014)

    I'm at my wits end. Any help would be greatly appreciated.

    Thank you!

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    Date fields should always be surrounded with "#" character like Between #3/1/2014# And #6/30/2014#.
    Further, conditional formatting will only apply a format but cannot grey it i.e. disable it so that users cannot select it. To achieve this, you need to use vba code in combo1's afterupdate event.
    If Me.Combo1 Between #3/1/2014# And #6/30/2014# then
    Me.Combo2.Enabled=False
    Else
    Me.Combo2.Enabled=True
    EndIf

  3. #3
    Gary Childress is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    34
    Quote Originally Posted by amrut View Post
    Date fields should always be surrounded with "#" character like Between #3/1/2014# And #6/30/2014#.
    Further, conditional formatting will only apply a format but cannot grey it i.e. disable it so that users cannot select it. To achieve this, you need to use vba code in combo1's afterupdate event.
    If Me.Combo1 Between #3/1/2014# And #6/30/2014# then
    Me.Combo2.Enabled=False
    Else
    Me.Combo2.Enabled=True
    EndIf
    Thanks you amrut! It seems to be working now.

  4. #4
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    Glad to help ! Mark the thread as solved

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 12
    Last Post: 01-23-2014, 03:24 PM
  2. Replies: 1
    Last Post: 12-05-2013, 01:15 PM
  3. Filter Report by Optional Date Range and Combo Box
    By ARickert in forum SQL Server
    Replies: 3
    Last Post: 10-17-2012, 10:46 AM
  4. Replies: 4
    Last Post: 05-26-2012, 09:29 AM
  5. Unwanted grey combo box fields on form
    By wouterv81 in forum Forms
    Replies: 1
    Last Post: 04-25-2012, 02:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums