Results 1 to 5 of 5
  1. #1
    Refereejohn is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Location
    Glasgow, Scotland
    Posts
    11

    Change backcolour when a date becomes ripe.

    I have around ten dates in an Access form I want to change the colour orange or amber (to indicate a warning in my [30DaysDate] thirty days to go) and when the anniversary date [EDEDateStart] arrives ten will turn red, these are mandatory learning dates for e-learning. I have tried the following code for the first experiment: -
    Private Sub Form_Load()
    Dim Orange As Long
    Orange = RGB(255, 165, 0)
    If [30DaysDate] - [EDEStartDate] <= 30 Then [30DaysDate.BackStyle] = Orange


    Else: [30DaysDate.BackStyle] = 0
    End If
    End Sub

    Being a novice I am uncertain if I can use the If Function for this. Even if I use an Expression in Conditional Formatting I would need the date the e-learning started to remain a constant (Date() would always be the current date). I would have to repeat the code with name changes I know but if I could find a code that would do this I’d be grateful. The amber or orange Backcolour would trigger thirty days before the anniversary date with the EDEStartDate turning red when the person went out of compliance.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    You will need to use the Current event of the form instead of the load one and the backcolor property (set it for 42495 for orange- see http://www.endprod.com/colors/invcol.htm for Access numeric codes).

    Cheers,
    Vlad

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Code is only practical if the form is in single view. Otherwise, only the selected (or first) record is affected. If the form is in continuous or datasheet view, you'd want to use Conditional Formatting.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Actually, every Record in Continuous or Datasheet view would be affected...but they'd all be affected/formatted based on the condition of the current Record.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Good point, I didn't say that very well.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 06-25-2016, 02:00 PM
  2. Year Date Change?
    By aellistechsupport in forum Queries
    Replies: 3
    Last Post: 01-19-2015, 09:08 PM
  3. Replies: 2
    Last Post: 07-15-2014, 12:00 PM
  4. How to Change Date Format
    By bulbul4u in forum Queries
    Replies: 1
    Last Post: 04-01-2011, 03:02 PM
  5. Change Date Into Number
    By greenbag in forum Queries
    Replies: 0
    Last Post: 11-14-2008, 04:43 PM

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