Results 1 to 9 of 9
  1. #1
    T_Tronix is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    28

    Change color of combo-box text based on Query/Table comparison

    I have a table with all employees and I've create a query to find specific employees from that table based on a specific criteria.



    Now I want to show a combo-box with all the employee names in it but the one that also appear in the query would show up in a different color.

    I am assuming this should be written in VBA but I am unsure how to compare my table values to the query values....

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Do you mean you want the names in the dropdown list to be different colors?

    I don't think that is at all possible.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    T_Tronix is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    28
    Quote Originally Posted by June7 View Post
    Do you mean you want the names in the dropdown list to be different colors?

    I don't think that is at all possible.

    So is there a way to make a button that changes the combo-box data feed? Like lets say I display record in the combo-box derived from Query1 but when I press the button I want it to display record from Query2...

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Might be easier for the reader to understand your issue if you posted the query sql. Or told us more about your Employee table and the criteria you are dealing with.
    Sometimes just telling us WHAT you are trying to accomplish, in plain English, will get some advice and comments.

  5. #5
    T_Tronix is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    28
    I have the following tables:

    Employees
    Tasks

    A query to find which of the Employees is available for a new task:

    SELECT Tasks.Resource_F, Tasks.Resource_L, Tasks.Resource_ACF2ID
    FROM Tasks, CachedDates
    WHERE (((Tasks.End_Date) Not Between [CachedDates].[SDate] And [CachedDates].[EDate])) OR (((Tasks.Start_Date) Not Between [CachedDates].[SDate] And [CachedDates].[EDate]));

    Now I've created a combo-box that allows to choose an available Employee based on the query result. But what if the person wants to see the full list of employees in that combo-box rather then only the ones available?

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  7. #7
    T_Tronix is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    28
    Yes, there could be an employee working on several tasks and also a task worked on by several employees.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I don't see how that query shows all available employees. To find all available employees requires a query that has both Employees and Tasks tables.

    Can change the combobox RowSource in some event. The trick is figuring out the event(s). It's nice to use event(s) that will do this automatically and not burden the user with another click. Sometimes need more than one event to accomplish that. Could be the AfterUpdate event of textboxes for date entry. And/Or form Current event. For a new record certainly need full list of employees. Once dates are entered, want restricted list.

    If Not IsNull(Me.SDate) Or Not IsNull(Me.EDate) Then
    Me.Combobox.RowSource = "SELECT this SQL"
    Else
    Me.Combobox.RowSource = "SELECT other SQL"
    End If
    Me.Combobox.Requery
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Change field color based on result
    By dniezby in forum Programming
    Replies: 1
    Last Post: 05-01-2013, 09:43 PM
  2. Text box change color
    By Ray67 in forum Forms
    Replies: 14
    Last Post: 11-19-2012, 04:06 PM
  3. Replies: 4
    Last Post: 12-25-2011, 06:31 PM
  4. Using an event to change color of text.
    By michaeljohnh in forum Programming
    Replies: 3
    Last Post: 08-30-2010, 12:30 PM
  5. Replies: 3
    Last Post: 07-05-2010, 10:46 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