Please help, I am rushing against the clock like a marathon runner desperate for H20

Wag2016

Registered User.
Local time
Today, 16:13
Joined
Mar 5, 2016
Messages
24
I have some vba performing some conditional formatting. Basic, no frills. I need help to expand what I already have.

Background: I have a textbox (SQ1C) that needs to turn green when option 1 of the option group is chosen, needs to turn red when option 2 is chosen and if option 3 is chosen, it needs to turn yellow AND then prompt the user to enter a remark in another textbox, maybe with a setfocus?

What I am starting with turns the other textbox red if options 2 or 3 are chosen. I have nothing for green. I can't seem to pull it all together.

PLEASE HELP! I am against the clock. The big bosses want color coding.

Here is the code.
SQ2C is the new textbox
SQ2F is the option frame containing 3 options.
SQ2R is the remark field.

Code:
'------------------------------------------------------------
' SQ1
'------------------------------------------------------------
Private Sub SQ2F_AfterUpdate()
If (SQ2F = 2 Or SQ2F = 3) And Len(Me.SQ2R & vbNullString) = 0 Then
Me.SQ2R.BackColor = RGB(255, 0, 0)
Else
Me.SQ2R.BackColor = RGB(255, 255, 204)
End If
End Sub
 Private Sub SQ2R_AfterUpdate()
If (SQ2F = 2 Or SQ2F = 3) And Len(Me.SQ2R & vbNullString) = 0 Then
Me.SQ2R.BackColor = RGB(255, 0, 0)
Else
Me.SQ2R.BackColor = RGB(255, 255, 204)
End If
 End Sub
 
Have you looked at actual Conditional Formatting? Conditional Formatting is a design time feature provided by Access that you can use without code, and you can test the values of controls, and select the appearance of the target control, and so on. For what you are doing, look for Conditional Formatting on your toolbar.
 
Have you looked at actual Conditional Formatting? Conditional Formatting is a design time feature provided by Access that you can use without code, and you can test the values of controls, and select the appearance of the target control, and so on. For what you are doing, look for Conditional Formatting on your toolbar.


I tried, I am not familiar with it, but forgive me I just couldn't seem to formulate an expression that does the prompt to the remark field. It is probably staring me in the face, but I keep going back to the code I already have because it worked.
 
Don't know if this is right or not...
Code:
Private Sub Form_Current()
    doValidation
End Sub

Private Sub SQ2F_Click()
    doValidation
End Sub

Private Sub SQ2R_Change()
    doValidation
End Sub

Private Sub doValidation()
    Select Case SQ2F
        Case 1: SQ2R.BackColor = vbGreen
        Case 2: SQ2R.BackColor = vbRed
        Case 3
            SQ2R.BackColor = vbYellow
            If "" & SQ2C = "" Then
                SQ2R = "Oi U! Enter a comment"
                SQ2C.SetFocus
            End If
    End Select
End Sub
 
Don't know if this is right or not...
Code:
Private Sub Form_Current()
    doValidation
End Sub

Private Sub SQ2F_Click()
    doValidation
End Sub

Private Sub SQ2R_Change()
    doValidation
End Sub

Private Sub doValidation()
    Select Case SQ2F
        Case 1: SQ2R.BackColor = vbGreen
        Case 2: SQ2R.BackColor = vbRed
        Case 3
            SQ2R.BackColor = vbYellow
            If "" & SQ2C = "" Then
                SQ2R = "Oi U! Enter a comment"
                SQ2C.SetFocus
            End If
    End Select
End Sub


Thank you! I will try that out!
 
Hi everyone, I just wanted to share my result. I tried the conditional formatting and got desired results on all three colors. I added another rule to the Remark field that said if the option frame was 3 then it would set focus. All done - very simple now that I am familiar with CF. Don't have to wrestle with code!
 

Users who are viewing this thread

Back
Top Bottom