Results 1 to 5 of 5
  1. #1
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    109

    conditional formatting based on user ID

    HTML Code:
    I have a dBase with login form based on table tbl_User and under [Group] column one of the users is “checker”. The database also contains form frmLengthCalc. What I am trying to accomplish is that if the checker changes any value on frmLengthCalc (in text box  “txtVlv_F150_Qty” for example), the text changes colour to red and bold. I tried to use vba but the code changes the text to red for the entire column not the record and if somebody else with different rights logs in the colour goes back to black again.
    Here is the code
    Code:
    Private Sub txtVlv_F150_Qty_AfterUpdate()
    Select Case U_Groups
        Case "Checker"
        With Forms!frmLengthCalc
        Me.txtVlv_F150_Qty.ForeColor = vbRed
        Me.txtVlv_F150_Qty.FontBold = True
        End With
    End Sub
    HTML Code:
    I am guessing conditional formatting is the way to go so I tired but it didn’t get me anywhere either.
    I used the following conditions to format [txtVlv_F150_Qty] textbox
    Expression Is [tbl_User]![Group]="Checker"
    And changed the text color to red and bold but it doesn’t do anything and doesn’t give me an error either.
    Wonder if somebody can help me with that.


  2. #2
    Beetle is offline Unrelatable
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    Camp Swampy (Denver, CO)
    Posts
    207
    It sounds like you are using a continuous (or perhaps datasheet) form, so you are going to have to use conditional formatting for this. However, you are not going to be able to use the Group field to determine the action for the following reasons;

    1) You only want the text to be red if the Group is Checker, and then only if they have changed or updated certain fields

    2) If the Group is not Checker, you still want the text to be red if had previously been changed by a Checker

    My suggestion is the following (untested)

    1) Add a boolean (Yes/No) field to the table to use as a flag
    2) In the After Update event of certain controls on your form set this flag to True if the field was changed by a Checker
    3) use this flag field in your conditional formatting expression to determine the color of the text.

  3. #3
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    109
    Beetle, I have done as instructed but the entire row gets red text, not only current record.

    I have created only one checkbox "ChckChecker" for the entire form and behind each control I put the following code
    'The one listed below is for one control
    Private Sub txtVlv_F150_Qty_AfterUpdate()
    If U_Groups = "Checker" Then
    Me.ChckChecker = True
    Else
    Me.ChckChecker = False
    End If
    End Sub

    For conditional formatting:
    Expression is [ChckChecker]=-1

    Do I have to have separate check box for each record ( I have 40 of them) or is there another way to limit the number of checkboxes?

  4. #4
    Beetle is offline Unrelatable
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    Camp Swampy (Denver, CO)
    Posts
    207
    The boolean field needs to be at the table level, not the form level. Even if you add a check box to each row (rather than a single check box in the header, or wherever you have it now), it won't work the way you need unless it is bound to a field in a table or query. This is due to the nature of the way unbound controls behave on continuous forms. I have attached a rough example file you can look at. If you open the form, select Checker as the Group, then add a new row or update one that is not already flagged, you'll see that the text for that row changes to red. The After Update event of each text box sets the flag based on whether or not it was updated by a Checker. I'm sure you will need to tweak this some to get it to work exactly the way you want for your scenario, but it should get you started.
    Attached Files Attached Files

  5. #5
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    109
    Beetle
    Thank you for your help, after some changes you suggested it works the way it suppose to.

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

Similar Threads

  1. Conditional Formatting based on result
    By Skyace00 in forum Reports
    Replies: 1
    Last Post: 01-13-2016, 05:19 PM
  2. Conditional Formatting Based On Another Column
    By Rustin788 in forum Reports
    Replies: 3
    Last Post: 08-13-2014, 01:52 PM
  3. Conditional Formatting based on another field - Part II
    By Harley Guy in forum Programming
    Replies: 8
    Last Post: 10-17-2013, 12:46 PM
  4. Replies: 5
    Last Post: 10-15-2013, 07:49 AM
  5. Replies: 11
    Last Post: 12-21-2011, 09:48 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