Solved Vb error on changing the color of a two fields (3 Viewers)

Jomat

Member
Local time
Today, 04:04
Joined
Mar 22, 2023
Messages
66
Hi all.
I'm getting an error when I run the following codes.
I have two text field that changes colors on a form based on a subform.
I think the problem is when the subform field is blank.

I'm getting the error when I navigate on a single form to the next form that have a blank amount in it's subform.
Runtime error - you entered an expression that has no value.

If anyone have some time to help look over it.

Code:
Private Sub Form_Timer()
If Nz(Forms!MYVIEWS!COOKIES!AMOUNT, "") = "" Then
        WARNINGSIGN1.BackColor = vbWhite
        WARNINGSIGN1.ForeColor = vbWhite
        Else
If Me.Status = "Active" Or Forms!MYVIEWS!COOKIES!AMOUNT > 200 Then
    If WARNINGSIGN.BackColor = vbWhite Then
        WARNINGSIGN.BackColor = vbRed
        WARNINGSIGN.ForeColor = vbWhite
    Else
        WARNINGSIGN.BackColor = vbWhite
        WARNINGSIGN.ForeColor = vbRed
End If
End If
End If
End Sub

Thank you.
 
Probably should just look up the value from the source table rather than on the subform.
 
Probably should just look up the value from the source table rather than on the subform.
Sorry I forgot to mention, the amount is a form caculate field from a query.
 
Thanks guys. I found the errors.. i was stuck on this for two days.

For example. I have:
Nz(Forms!MYVIEWS!COOKIES!AMOUNT, "")
but it should be:
Nz(Me.MYVIEWS!COOKIES.Form!AMOUNT, "")

Also added:
Dim amount As Variant
And finally:
On Error Resume Next
On Error GoTo 0

Thank you for all the inputs. Have a wonderful day/night.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom