Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Text Color Based on Pop Up Form Value

Status
Not open for further replies.
Mar 9, 2007
48
US
Hello Ladies and Gentlemen. Once again I come to you with what I'm sure is an easy solution but the solution is some how eluding me. The issue is:

I have a Main Form (Main Form is not the true name) which is bound to a table. Main Form has a button called [Add Comments]. When the button is clicked it opens a pop up form called [CommentsFrm] (bound to a query). On this form is a text box called [CommentsBox] in which the user updates. What I want to occur is when the pop up form is closed and it is not null the fore color on the [Add Comments] button label should turn from black to red. The code I'm using on the After Update Event of the [CommentsBox] is:

Private Sub CommentsBox_AfterUpdate()
If IsNull(Me![CommentsBox]) = True Then
Forms![MainForm].[Add Comment_Label].ForeColor = vbRed
Else: Forms![MainForm].[Add Comment_Label].ForeColor = vbBlack
End If

Nothing occurs when the CommentsBox is updated. Not an eror message, nothing. Any guidance is appreciated.
 

I'd put the code on the form's close event or the click event of the button used to close the popup form. If you have nothing in the text box, the after update event will not fire.
Code:
Private Sub cmdClose_Click()
    If Me.txtComments = "" Or IsNull(Me.txtComments) Then
        Forms!frmMainForm!lblComment.ForeColor = vbRed
    Else
        Forms!frmMainForm!lblComment.ForeColor = vbYellow
    End If
    Debug.Print txtComments
    DoCmd.Close acForm, "frmPopUp"
End Sub


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top